You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a schema validation using Joi which puts a field as required. This field sometimes can be hidden and I want to skip its validation when submitting the rest of the form. What's the best way of doing that?
constschema=Joi.object<IShippingInfoFormData>({name: Joi.string().required(),age: Joi.number().required(),// <- this field can be hidden and I want to skip its validation when submitting the form})const{ ... }=useForm({defaultValues: {},resolver: joiResolver(schema,JoiResolverOptions),criteriaMode: 'all',shouldUnregister: true,})return(<form ...><inputname="name".../>{showAge&&<inputname="age".../>}</form>)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everyone! 👋
I have a schema validation using Joi which puts a field as required. This field sometimes can be hidden and I want to skip its validation when submitting the rest of the form. What's the best way of doing that?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions