Skip to content

Tag: yup

Fields in Formik (validated on Yup) are constantly displaying an error as if they are empty or invalid. find codesandbox-link attached below

//The onChange variable in the fields is updated on the above code. I am unable to find the solution towards making the below fields function properly. I tried using formik’s setFieldValue however It didn’t work The below code is the return function: Sandbox Answer Simply use Formik’s handleChange event and values. You don’t need to create custom functions or states

start and end date should be different for one year

Hi there I’m using Yup as a validator for one of my schemas This is my code here for validating schema This works but I can add the same date for the start date and end date. I want that end date to be different and higher than start date Thanks a lot Answer You can try Yup.when to handle

How can I make a yup number accept nullable values?

I have the following yup check: And right now if I leave the field blank, it validates as false. Is there any way to make yup.number() accept empty values? I have tried: But it doesn’t seem to work. Any ideas on how I can make such thing happen? Answer You have to pass true to nullable – nrOfApples: yup.number().min(0).max(999).nullable(true); From: