RegexRule

open class RegexRule : ValidationRule<String>

RegexRule is a subclass of ValidationRule that defines how a regular expression is validated.

  • Method used to initialize RegexRule object.

    Declaration

    Swift

    public init(regex: String, message: String = "is invalid.")

    Parameters

    regex

    Regular expression string to be used in validation.

    message

    String of error message.

    Return Value

    An initialized RegexRule object.

  • Method used to validate the provided value.

    Declaration

    Swift

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

    Parameters

    value

    String to be checked for validation.

    Return Value

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