2017-10-28 97 views
0

如果account_name字段不具有值「0」,那麼我需要一個字段項目。我想要驗證此方案在laravel如果其他字段沒有特定值,則爲必填字段

eg if account_name = '0' -project_name field is not required 
    if account_name = '1' - project_name field is required 


$this->validate($request,[ 
    'project_name'=>'required_without:account_name,0', 
    ]); 

回答

2

嘗試使用required_unless!那麼名稱將是必需的,除非account_name等於0.

​​
相關問題