Skip to content

Instantly share code, notes, and snippets.

@laevandus
Last active August 14, 2019 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laevandus/00acbe254738f6327b19627fe6708b65 to your computer and use it in GitHub Desktop.
Save laevandus/00acbe254738f6327b19627fe6708b65 to your computer and use it in GitHub Desktop.
@propertyWrapper
struct EmailValidated {
private var value: String?
var wrappedValue: String? {
get {
return value
}
set {
value = {
guard let trimmedString = newValue?.trimmingCharacters(in: .whitespacesAndNewlines) else { return nil }
return validate(trimmedString)
}()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment