LengthRule
public class LengthRule : ValidationRule<String>
LengthRule
is a subclass of ValidationRule
that defines how length is validated with min & max limits.
-
Initializes a
LengthRule
object to verify that length of value is in the range of min & max.Declaration
Swift
public init(min: Int, max: Int, message: String? = nil)
Parameters
min
Minimum required length of value.
max
Maximum required length of value.
message
String of error message.
Return Value
An initialized object.
-
Method used to validate the provided value.
Declaration
Swift
public override func validate(_ value: String?) -> String?
Parameters
value
String value to be checked for validation.
Return Value
Error Message String. nil if validation is successful;
String
if validation fails.