'Validate post sub item in AdonisJs

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'})])
  })


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source