TanStackT
TanStack13mo ago
2 replies
verbal-lime

Validate single field when change happend

Hello everyone! I have a problem with next case: I have form with couple of fields, also I have my validation schema written using yup. That schema validates whole form, but I want to validate single field when user types anything there. Currently it looks like this

<form.Field
    name={item.name as keyof FormSchema}
    key={index}
    listeners={{
       onChange: onChange
    }}
    validatorAdapter={yupValidator()}
    validators={{
        onChange: validationSchema,
    }}
  >

Validation doesn't work beacouse validationSchema provides validation for whole form. How can I solve this?
Was this page helpful?