Skip to content

Instantly share code, notes, and snippets.

@Sajjon
Created November 27, 2018 12:52
Show Gist options
  • Save Sajjon/2cee50902144d244bc988b13a510ea76 to your computer and use it in GitHub Desktop.
Save Sajjon/2cee50902144d244bc988b13a510ea76 to your computer and use it in GitHub Desktop.
Medium article: SLC part 1 - Validation
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