RegexRule
public class RegexRule : Rule
RegexRule
is a subclass of Rule that defines how a regular expression is validated.
-
Method used to initialize
RegexRule
object.Declaration
Swift
public init(regex: String, message: String = "Invalid Regular Expression")
Parameters
regex
Regular expression string to be used in validation.
message
String of error message.
Return Value
An initialized
RegexRule
object, or nil if an object could not be created for some reason that would not result in an exception. -
Method used to validate 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.
-
Method used to dispaly error message when text field fails validation.
Declaration
Swift
public func errorMessage() -> String
Return Value
String of error message.