I need to validate a request account_type if it is either 'Personal' or 'Organizational' So that i can validate other field by required if account_type,personal.Heres the code that i have tried.
'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'
Method Illuminate\Validation\Validator::validateOptions does not exist. This is the error that i got.
CodePudding user response:
if you only have these 2 options (PERSONAL,ORGANIZATIONAL), then use in
instead of options
. Like this :
'account_type' => 'required|in:PERSONAL,ORGANIZATIONAL',
It works for me.