ExactLengthRule

public class ExactLengthRule : ValidationRule<String>

ExactLengthRule is a subclass of ValidationRule that is used to make sure a the value has an exact length.

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

    Declaration

    Swift

    public init(length: Int, message: String = "")

    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 length of string.

    Declaration

    Swift

    public override func validate(_ value: String?) -> String?

    Parameters

    value

    Any value to be checked for validation.

    Return Value

    Error Message. nil if validation is successful; String if validation fails.