php - Laravel validator for nested array


Am using the Laravel Validator class to do some basic validation on an array.

My array :


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 useValidator::make($employee, $rules, $messages);

How do I write the rule and messages for$employee[department]['name'] and$employee[department]['address'] using same rules and messages variables?




Use dot notation for nested array:

People are also looking for solutions to the problem: javascript - Using JS OOP with PHP


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.