RequiredRule

public class RequiredRule: Rule

RequiredRule is a subclass of Rule that defines how a required text field is validated.

  • Initializes RequiredRule object with error message. Used to validate a field that requires text.

    Declaration

    Swift

    public init(message : String = "This field is required")

    Parameters

    message

    String of error message.

    Return Value

    An initialized RequiredRule object, or nil if an object could not be created for some reason that would not result in an exception.

  • Validates a text field.

    Declaration

    Swift

    public func validate(value: String) -> Bool

    Parameters

    value

    String to checked for validation.

    Return Value

    Boolean value. True if validation is successful; False if validation fails.

  • Used to display error message when validation fails.

    Declaration

    Swift

    public func errorMessage() -> String

    Return Value

    String of error message.