yup-phone
yup-phone copied to clipboard
Overrides yup's required() error message when no value is present.
Here is a snippet from my yup validation schema. I would like to pass a message into the required function to display something user-friendly if they don't enter any text.
emergencyPhoneNumber: Yup.string()
.phone()
.required('Emergency contact phone number is required.'),
I know I can provide a custom error message through phone()
however, as this is an add-on to yup, it should support yup's expected behavior. If possible, I would like to be able to provide an error message for when a user input's an invalid phone number and a required message if they don't input anything.
Having this same issue.
If you put chain it like Yup.string().required("Message").phone() you should get the required message.