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 would like to have my form start with empty form fields, but require to pass a validation where the fields are non-empty.
constschema=Yup.object().shape({price: Yup.number().required()});useFormik<InferType<typeofschema>>({validationSchema: schema,initialValues: {price: undefined,// This errors because it's not a number},onSubmit(value){// handle submit}});
If I Partial<> the useFormik generic I then get an onSubmit value that doesn't match with my schema validator.
I think it's totally reasonable to provide empty input fields when a form is presented to a user, and expect them to fill them with the correct value. How can I do this with Formik, Yup, and TypeScript?
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
-
I would like to have my form start with empty form fields, but require to pass a validation where the fields are non-empty.
If I
Partial<>
theuseFormik
generic I then get anonSubmit
value that doesn't match with my schema validator.I think it's totally reasonable to provide empty input fields when a form is presented to a user, and expect them to fill them with the correct value. How can I do this with Formik, Yup, and TypeScript?
Beta Was this translation helpful? Give feedback.
All reactions