Issue
Validate post sub item in AdonisJs.
I can't validate a sub item of the post. I believe it is not found.
I need to validate "codigo" that is inside "nfe"
Request
{
nfe: {
codigo: '56456',
motorista: 'NOME',
contato: 'CONTATO',
casa: true
},
fornecedor: 'ALIMENTOS',
lab: 'sim',
}
Controller
await request.validate(NfeValidator)
Validator
public schema = schema.create({
'nfe.codigo': schema.string({trim: true}, [rules.unique({table: 'nfes', column: 'codigo'})])
})
Solution
A field was included in the root of the request post to be checked.
Answered By - marcelo.delta
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.