Skip to content

How to validate a key of an object #3648

Answered by venuziano
venuziano asked this question in Q&A
Discussion options

You must be logged in to vote

I managed to solve the issue like this:

When using .touched object, use like this > values?.touched?.Contribuinte && values?.touched?.Contribuinte?.CtbTipo
And when using .errors > values?.errors.Contribuinte?.CtbTipo

Code example:

<div className='fv-row mb-7 me-4 w-100'>
              <label className='required fw-bold fs-6 mb-2'>Tipo</label>
              <select
                {...values?.getFieldProps('Contribuinte.CtbTipo')}
                className={clsx(
                  'form-select form-select-solid',
                  { 'is-invalid': values?.touched?.Contribuinte && values?.touched?.Contribuinte?.CtbTipo && values?.errors.Contribuinte?.CtbTipo },
                  {
         …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by venuziano
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant