Validate phone number with Yup?

Hi right now I’am solving same problem as you and I found possible solution. Validate phone number with string that matches Regex const phoneRegExp = /^((\\+[1-9]{1,4}[ \\-]*)|(\\([0-9]{2,3}\\)[ \\-]*)|([0-9]{2,4})[ \\-]*)*?[0-9]{3,4}?[ \\-]*[0-9]{3,4}?$/ phoneNumber: Yup.string().matches(phoneRegExp, ‘Phone number is not valid’) You can search for different Regex Expressions and validate it. I’ve used Regex from this article https://www.sitepoint.com/community/t/phone-number-regular-expression-validation/2204

Validation using Yup to check string or number length

This check leads to the best validation experience: Yup.string() .required() .matches(/^[0-9]+$/, “Must be only digits”) .min(5, ‘Must be exactly 5 digits’) .max(5, ‘Must be exactly 5 digits’) output: 12f1 // Must be only digits 123 // Must be exactly 5 digits 123456 // Must be exactly 5 digits 01234 // valid 11106 // valid Demo: … Read more

Conditional Validation in Yup

You probably aren’t defining a validation rule for the showEmail field. I’ve done a CodeSandox to test it out and as soon as I added: showEmail: yup.boolean() The form started validation correctly and no error was thrown. This is the url: https://codesandbox.io/s/74z4px0k8q And for future this was the correct validation schema: validationSchema={yup.object().shape({ showEmail: yup.boolean(), email: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)