@woogygun any luck on this?
Aug 16, 2017
3
Level 7
Validation Errors For Nested Fields
Im trying to validate a nested array of values with laravel. The fields are getting posted off with axios via vuejs as follows.
{
name: 'john doe',
staff_profile: {
mobile: '000 111 2222'
}
{
Im validating the fields via a FormRequest object in laravel as follows:
return [
'name' => 'required'
'staff_profile.mobile' => 'required'
];
If the validation fails the errors are returned as follows:
name: ["The name field is required."],
staff_profile.mobile: ["mobile field required"]
note how the property for the mobile field has come back with a dot in the property name, this makes it impossible for me to access the error in vue
{{ errors.staff_profile.mobile[0] }} does not work.
Is there a way to get laravel to return the errors as follows:
name: ["The name field is required."],
staff_profile: {
mobile: ["mobile field required"]
}
I know that i could access the data as per the below line, it just feels like its breaking the mould
{{ errors['staff_profile.mobile'][0] }}
Please or to participate in this conversation.