I was trying out Regex to validate Nigerian mobile numbers without the country code (+234).
Here is what I came up with.
Not sure if it is perfect though. Any other ideas?
import * as yup from "yup"; /* Regex to match Nigeria mobile number with the country code +234 It matches: 08053303925 09055303925 08145327190 */ const phoneRegExp = /^([0]{1})[0-9]{10}$/ cconst schema = yup.object().shape({ phone: yup.string().matches(phoneRegex, "Invalid phone number."), }); export default schema;
Top comments (3)
Pardon, this doesn't work
Some comments may only be visible to logged-in visitors. Sign in to view all comments.