Created
August 5, 2018 22:58
-
-
Save Arrlindii/843deed64ad37fe6d4555460bc051276 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func validatedEmail(_ value: String) throws -> String { | |
| do { | |
| if try NSRegularExpression(pattern: "^[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}$", options: .caseInsensitive).firstMatch(in: value, options: [], range: NSRange(location: 0, length: value.count)) == nil { | |
| throw ValidationError("Invalid e-mail Address") | |
| } | |
| } catch { | |
| throw ValidationError("Invalid e-mail Address") | |
| } | |
| return value | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment