jquense / yup

Dead simple Object schema validation
MIT License
22.72k stars 925 forks source link

If a field is not required and typeError is specified, on not entering anything also, it gives an error(typeError) #2214

Open vishal-gits opened 4 months ago

vishal-gits commented 4 months ago

I am using validation for postalcode in a input box.

phone: yup .number() .max(9) .typeError("Provide in postalcode number format"),

When typeError() is given to phone(which is not specified required), and when nothing is entered for phone, then also it attaches a typeError to it. Ideally if nothing is entered and it is not specified "required", it should not give an error.