There is an official way to validate if an email address is valid without using regex?
I've already implemented this validation with regex:
public func validate(email:String)->Bool{
let regex:String = "\\A[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\z"
let emailTest = NSPredicate(format:"SELF MATCHES %@", regex)
return emailTest.evaluateWithObject(email)
}
I'm on this for a while and I'm looking for an official way to do this in swift/ios without writing my own logic, which in my opinion is more related to have bugs.