Skip to content

Instantly share code, notes, and snippets.

@vincent-pradeilles
Created September 25, 2017 17:26
Show Gist options
  • Save vincent-pradeilles/7bcac9e2a6813ddf70a0328c119229f1 to your computer and use it in GitHub Desktop.
Save vincent-pradeilles/7bcac9e2a6813ddf70a0328c119229f1 to your computer and use it in GitHub Desktop.
struct AccountNumber {
let number: String
init?(untrustedAccountNumber: Untrusted<String>) {
guard let validAcountNumber = AccountNumberValidator.validate(untrusted: untrustedAccountNumber)
else {
return nil
}
self.number = validAcountNumber
}
}
struct AccountNumberValidator: Validator {
static func validation(value: String) -> Bool {
return isValidAccountNumber(value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment