Validating array of objects

[{
“salesconsultant”: “test”,
“orderdate”: “06/21”,
“account”: “009l”,
“sport”: “testsport”,
“product”: “prod1”,
“purchasequantity”: 45,
“revenue”: 45,
“leadsource”: “test-1”
},{
“salesconsultant”: “test”,
“orderdate”: “06/21”,
“account”: “009l”,
“sport”: “testsport”,
“product”: “prod1”,
“purchasequantity”: 45,
“revenue”: 45,
“leadsource”: “test-1”
},…]
I want to validate each fields of an object.
Thanks in advance

Hey @chinnu! :wave:

Have you checked the documentation?

ya…But i didn’t find anything to validating nested object values.

Here it is https://indicative.adonisjs.com/docs/syntax-guide#_targeting_arrays

1 Like

it worked for me but the validation messages did not work, can you tell me how to fit in custom error messages?
Thank`s Guy

 get rules() {
    return {
      // validation rules
      // validation rules
      'enderecos.*.ds_cep': 'required'

    }
  }
get messages() {
    return {
      'enderecos.*.ds_cep': 'Você deve escolher um cep válido',
    }
  }

Hey @diogon01! :wave:

You need to add the name of the rule after your key.

'enderecos.*.ds_cep' must become 'enderecos.*.ds_cep.required'.

1 Like

Not working

Page not found sir.