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.1.
func isValidPhone(phone: String) -> Bool {
let phoneRegex = "^[0-9]{6,14}$";
let valid = NSPredicate(format: "SELF MATCHES %@", phoneRegex).evaluate(with: phone)
return valid
}
func isValidEmail(candidate: String) -> Bool {
let emailRegex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
var valid = NSPredicate(format: "SELF MATCHES %@", emailRegex).evaluate(with: candidate)
if valid {
valid = !candidate.contains("..")
}
return valid
}