CreditCardExpirationDateValidator class
CreditCardExpirationDateValidator extends TranslatedValidator to validate if a string represents a valid credit card expiration date.
This validator checks if the expiration date is in the format MM/YY, and optionally if the date is not expired.
Parameters:
- checkForExpiration Whether to check if the date is not expired. Defaults to true.
- regex The regular expression used to validate the expiration date format. Defaults to a standard expiration date regex.
- errorText The error message returned if the validation fails.
- checkNullOrEmpty Whether to check if the value is null or empty.
- Inheritance
-
- Object
- BaseValidator<
String> - TranslatedValidator<
String> - CreditCardExpirationDateValidator
Constructors
- CreditCardExpirationDateValidator.new({bool checkForExpiration = true, RegExp? regex, String? errorText, bool checkNullOrEmpty = true})
- Constructor for the credit card expiration date validator.
Properties
- checkForExpiration → bool
-
Whether to check if the date is not expired.
final
- checkNullOrEmpty → bool
-
Whether to check if the value is null or empty.
finalinherited
- errorText → String
-
The error message returned if the value is invalid.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- regex → RegExp
-
The regular expression used to validate the expiration date format.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- translatedErrorText → String
-
The translated error message returned if the value is invalid.
no setteroverride
Methods
-
isCreditCardExpirationDate(
String value) → bool - Check if the string is a valid credit card expiration date.
-
isNotExpiredCreditCardDate(
String value) → bool - Check if the string is not an expired credit card date.
-
isNullOrEmpty(
String? valueCandidate) → bool -
Checks if the value is null or empty.
Returns
true
if the value is null or empty, otherwisefalse
. The value is considered empty if it is a String, Iterable, or Map and it is empty or contains only whitespace characters. If the value is not a String, Iterable, or Map, it is considered empty if it isnull
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
validate(
String? valueCandidate) → String? -
Validates the value and checks if it is null or empty.
inherited
-
validateValue(
String valueCandidate) → String? -
Validates the value.
Returns
null
if the value is valid, otherwise an error message. Call validate() instead of this method when using the validator.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited