I am using react-hook-form V7.44.3 and I am validating a date but its input is optional, I have tried the following:
warranty_due_date: yup.date().optional(),
warranty_due_date: yup.date().notRequired(),
but I keep getting an error:
object { message: "warranty_due_date must be a date type, but the final value was: Invalid Date (cast from the value Invalid Date).", type: "typeError", ref: input#warranty_due_date.sc -hBxehG.eMfLfQ }
Hi,
I am using react-hook-form V7.44.3 and I am validating a date but its input is optional, I have tried the following: warranty_due_date: yup.date().optional(), warranty_due_date: yup.date().notRequired(),
but I keep getting an error: object { message: "warranty_due_date must be a
date
type, but the final value was:Invalid Date
(cast from the valueInvalid Date
).", type: "typeError", ref: input#warranty_due_date.sc -hBxehG.eMfLfQ }What should I do to avoid this error?