My request looks a bit like this:
"adults": {
"count": 2,
"persons": {
[
"name": "Anne",
"surname": "Doe",
],
[
"name": "Anne",
"surname": "Doe",
],
}
}
How can I easily verify using a custom Request that the count field matches the size of the persons?
Here's my Rules:
class CreateFamilyRequest extends ApiRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'adults' => ['array'],
'adults.number' => ['int'],
'adults.persons.*.name' => ['string'],
'adults.persons.*.surname' => ['string'],
];
}
}