Skip to content

Instantly share code, notes, and snippets.

@Arrlindii
Created August 21, 2018 17:48
Show Gist options
  • Select an option

  • Save Arrlindii/2d0e0bab3ba3c5a9828ca8f62c5f1314 to your computer and use it in GitHub Desktop.

Select an option

Save Arrlindii/2d0e0bab3ba3c5a9828ca8f62c5f1314 to your computer and use it in GitHub Desktop.
enum VaildatorFactory {
static func validatorFor(type: ValidatorType) -> ValidatorConvertible {
switch type {
case .email: return EmailValidator()
case .name(let fieldName) : return NameValidator(fieldName)
case .requiredField(let fieldName): return RequiredFieldValidator(fieldName)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment