Last active
August 14, 2019 12:37
-
-
Save laevandus/00acbe254738f6327b19627fe6708b65 to your computer and use it in GitHub Desktop.
This file contains 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
@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