I have a form which is generated dynamically after I call some APIs. after the api response is received, I am resetting the form using the
const someModelObject = { name: "", isActive: 0, date: null }
const validationSchema = Yup.object().shape({ name: Yup.String().required(),
isActive: Yup.number.required(), date: Yup.number().notRequired() })
const { reset } = useForm({
defaultValues: someModelObject,
resolver: yupResolver(validationSchema)
})
I am able to update the default values using reset function:
// after api call response
const moreCustomFieldsFromAPI = { custom1: "", custom2: "" }
reset({ ...someModelObject, ...moreCustomFieldsFromAPI })
But how do I update the resolver as it is obsolete when I add new form fields in the form controller? I want a formatted object when I call getValues(), some key values are required in integer format and some in string.