ValidationRule
public class ValidationRule
ValidationRule is a class that creates an object which holds validation info of a field.
-
the field of the field
Declaration
Swift
public var field:ValidatableField -
the errorLabel of the field
Declaration
Swift
public var errorLabel:UILabel? -
the rules of the field
Declaration
Swift
public var rules:[Rule] = [] -
Initializes
ValidationRuleinstance with field, rules, and errorLabel.Declaration
Swift
public init(field: ValidatableField, rules:[Rule], errorLabel:UILabel?)Parameters
fieldfield that holds actual text in field.
errorLabellabel that holds error label of field.
rulesarray of Rule objects, which field will be validated against.
Return Value
An initialized
ValidationRuleobject, or nil if an object could not be created for some reason that would not result in an exception. -
Used to validate field against its validation rules.
Declaration
Swift
public func validateField() -> ValidationError?Return Value
ValidationErrorobject if at least one error is found. Nil is returned if there are no validation errors.
ValidationRule Class Reference