Created
August 11, 2018 18:53
-
-
Save vialyx/148ee245f4694518df4da2ef956fd793 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
enum EmailValidationError: Error { | |
// TODO: - Cases | |
case empty | |
// TODO: - Cases can be declared on a single line | |
case noDomain(String) | |
case invalid(String) | |
} | |
extension EmailValidationError: LocalizedError { | |
var errorDescription: String? { | |
switch self { | |
case .invalid: | |
return "This email is incorrect. Please, try again" | |
case .empty: | |
return "This email is empty. Please, fill it" | |
case .noDomain: | |
return "This email without domain. Please, try again" | |
} | |
} | |
} | |
let error = EmailValidationError.empty | |
print("error: \(error.localizedDescription)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment