ExactLengthRule

public class ExactLengthRule : Rule

ExactLengthRule is a subclass of Rule that is used to make sure a the text of a text field is an exact length.

  • Initializes an ExactLengthRule object to validate the text of a text field against an exact length.

    Declaration

    Swift

    public init(length: Int, message : String = "Must be exactly %ld characters long")

    Parameters

    length

    Integer value of exact string length being specified.

    message

    String of error message.

    Return Value

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

  • Used to validate a text field.

    Declaration

    Swift

    public func validate(value: String) -> Bool

    Parameters

    value

    String to checked for validation.

    Return Value

    A boolean value. True if validation is successful; False if validation fails.

  • Displays error message if a text field fails validation.

    Declaration

    Swift

    public func errorMessage() -> String

    Return Value

    String of error message.