Protocols
The following protocols are available globally.
-
This protocol needs to be implemented in order to add a requirement to a wrapped type. Implementers receive the wrapped type and need to determine if its values fulfill the requirements of the wrapper type. ~~~ struct NonEmptyStringValidator: Validator { static func validate(value: String) -> Bool { return !value.isEmpty } } ~~~
See moreDeclaration
Swift
public protocol Validator
-
Allows behaviour to be added to a validated type via protocol extensions.
e.g., ~~~ typealias PhoneNumber = Validated
extension ValidatedType where ValidatorType == PhoneNumberValidator { var regionCode: String { return // Parse and return region code } }
…
let phoneNumber = try PhoneNumber(
See more00 1 917 555 2368
) print(\(phoneNumber.regionCode)
) ~~~Declaration
Swift
public protocol ValidatedType