Email Validation in Swift.

Ronak Patel
1 min readSep 8, 2020

--

Today, We’ll see the email validation.

static func isValidEmail(_ emailString: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: emailString)}

This function will not allow the user to enter a blank space in between or at the ending/starting of the email field and also check for the necessary required condition.

--

--

No responses yet