php - Laravel validator for nested array
Am using the Laravel Validator class to do some basic validation on an array.
My array :
$employee['name']='name'; $employee['address']='address'; $employee['department']['name']='deptname'; $employee['department']['address']='deptaddress';
I have the validation rules as below:
$rules = array( 'name'=> 'required', 'address' => 'required' )
And the custom messages as below :
$messages = array( 'name.required' => 'Employee Name is required', 'address.required' => 'Address is required' )
I will use
Validator::make($employee, $rules, $messages);
How do I write the rule and messages for
$employee[department]['address'] using same rules and messages variables?
Use dot notation for nested array: