ValidationRule
public class ValidationRule
ValidationRule is a class that creates an object which holds validation info of a text field.
-
the text field of the field
Declaration
Swift
public var textField:UITextField -
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 text field, rules, and errorLabel.Declaration
Swift
public init(textField: UITextField, rules:[Rule], errorLabel:UILabel?)Parameters
textFieldtext field that holds actual text in text field.
errorLabellabel that holds error label of text field.
rulesarray of Rule objects, which text 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 text field against its validation rules. - returns:
ValidationErrorobject if at least one error is found. Nil is returned if there are no validation errors.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