Condition
public protocol Condition : CustomStringConvertible
A Condition is the smallest sub element of the validation framework. It tells how a string must be structured or wat is has to contain or not. Validators are for storing those conditions and checking for violations of every condition.
Conditions are recommended working with regular expressions but can also contain their custom checking code for detecting violations in the string to check.
By returning a localized string in method localizedViolationString the
user can be informed in a convenient way what went wrong.
-
Localized string which described the kind of violation.
Declaration
Swift
var localizedViolationString: String { get set } -
A regular expression string which the validated string is matched against.
Declaration
Swift
var regex: String { get } -
If set to
falsethe user is not able to enter characters which would break the condition.Declaration
Swift
var shouldAllowViolation: Bool { get set } -
Initializer that creates a condition based on default values.
Declaration
Swift
init() -
check(_:)Default implementationCheck the custom condition.
Note
Checking anilvalue should always returnfalse.Default Implementation
Declaration
Swift
func check(_ text: String?) -> BoolParameters
textStringto check.Return Value
Whether the condition check passed or failed.
-
descriptionExtension methodDeclaration
Swift
var description: String { get }
View on GitHub
Condition Protocol Reference