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
false
the 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 anil
value should always returnfalse
.Default Implementation
Declaration
Swift
func check(_ text: String?) -> Bool
Parameters
text
String
to check.Return Value
Whether the condition check passed or failed.
-
description
Extension methodDeclaration
Swift
var description: String { get }