Created
November 27, 2018 12:52
-
-
Save Sajjon/2cee50902144d244bc988b13a510ea76 to your computer and use it in GitHub Desktop.
Medium article: SLC part 1 - Validation
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 Validation<Validated> { | |
| case valid(Validated) | |
| case invalid(errorMessage: String) | |
| var asValidated: Validated? { | |
| switch self { | |
| case .valid(let validated): return validated | |
| default: return nil | |
| } | |
| } | |
| var isValid: Bool { | |
| return asValidated != nil | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment