Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overrides yup's required() error message when no value is present. #762

Open
mantism opened this issue Jul 16, 2022 · 2 comments
Open

Overrides yup's required() error message when no value is present. #762

mantism opened this issue Jul 16, 2022 · 2 comments

Comments

@mantism
Copy link

mantism commented Jul 16, 2022

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.

@aaronbdixon
Copy link

Having this same issue.

@aaronbdixon
Copy link

If you put chain it like Yup.string().required("Message").phone() you should get the required message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants