i am using the following code for phone number validation. But i am getting the following error. I cant able to proceed further. Help us to take it forward.
Swift 4 & Swift 5:
func isValidPhone(phone: String) -> Bool {
let phoneRegex = "^[0-9+]{0,1}+[0-9]{5,16}$"
let phoneTest = NSPredicate(format: "SELF MATCHES %@", phoneRegex)
return phoneTest.evaluate(with: phone)
}
func isValidEmail(email: String) -> Bool {
let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}"
let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
return emailTest.evaluate(with: email)
}