Answers for "yup validation for number"

1

yup number validation custom message

numberFiled: Yup.number()
                        .typeError('you must specify a number')
                        .min(0, 'Min value 0.')
                        .max(30, 'Max value 30.')
Posted by: Guest on April-22-2021
0

phone number validation in yup

Yup.object({
  phone: Yup.string()
      .required("This field is Required")
      .matches(
        /^((\+[1-9]{1,4}[ \-]*)|(\([0-9]{2,3}\)[ \-]*)|([0-9]{2,4})[ \-]*)*?[0-9]{3,4}?[ \-]*[0-9]{3,4}?$/,
        "Phone number is not valid"
      )
})
Posted by: Guest on September-26-2021
2

yup phone number

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')
Posted by: Guest on July-03-2020

Code answers related to "yup validation for number"

Browse Popular Code Answers by Language