INNER CODE UNIT · TypeScript
phoneRegex
slowfound/next-prisma-tailwind-ecommerce · packages/regex/src/index.ts:2
const phoneRegex = /^\+(?:[0-9] ?){6,14}[0-9]$/
const iranianPhoneRegex = /^0[0-9]{2,}[0-9]{7,}$/
export function isEmailValid(email: string) {
return emailRegex.test(email)
}
export function isPhoneNumberValid(phoneNumber: string) {
return phoneRegex.test(phoneNumber)
}
export function isIranianPhoneNumberValid(phoneNumber: string) {
return iranianPhoneRegex.test(phoneNumber)
}