我需要驗證一個請求的帳戶型別,如果它是 "個人 "或 "組織"。 這樣我就可以通過required if account_type,personal來驗證其他欄位。下面是我試過的代碼。
'account_type' => 'required|options:PERSONAL,ORGANIZATIONAL',
'per_client_name' => 'required_if:account_type,PERSONAL|string',
'per_street' => 'required_if:account_type,PERSONAL',
'per_address' => 'required_if:account_type,PERSONAL',
'org_name' => 'required_if:account_type,ORGANIZATIONAL',
'org_type' => 'required_if:account_type,ORGANIZATIONAL',
'org_cont_name' => 'required_if:account_type,ORGANIZATIONAL'
方法IlluminateValidationValidator::validateOptions不存在。這是我得到的錯誤。
uj5u.com熱心網友回復:
如果你只有這2個選項(PERSONAL,ORGANIZATIONAL),那么使用in而不是options。像這樣 :
'account_type' => 'required|in:PERSONAL,ORGANIZATIONAL',
這對我來說很有效。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/324230.html
標籤:
上一篇:根據價格過濾器過濾產品(從到)。
