EasyValidatorMixin mixin
A mixin that provides easy validation functionality.
This mixin extends the functionality of the EasyValidator class by adding a method to retrieve error messages. The getErrorMessage method takes a message and an optional replacement string, and returns the error message with any placeholders replaced by the replacement string. If no replacement string is provided, the method returns the error message as is.
Example usage:
mixin EasyValidatorMixin on EasyValidator {
String getErrorMessage(String message, [String? replacement]) {
final msg = errorMessage ?? message;
return replacement != null ? msg.replaceAll('{0}', replacement) : msg;
}
}
See also:
- EasyValidator, the base class that this mixin extends.
- Superclass Constraints
- Mixin Applications
-
- ContainsNumbersValidator
- ContainsValidator
- EmailValidator
- EndWithValidator
- EqualLengthValidator
- EqualToValidator
- MaxLengthValidator
- MaxWordCountValidator
- MinLengthValidator
- MinWordCountValidator
- NotContainsValidator
- NotEndWithValidator
- NotEqualLengthValidator
- NotEqualToValidator
- NotStartWithValidator
- RegularExpressionValidator
- RequiredValidator
- StartWithValidator
Properties
- errorMessage → String?
-
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getErrorMessage(
String message, [String? replacement]) → String - Returns the error message with optional replacement.
-
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? value) → String? -
Validates the given
value
and returns an error message if the value is invalid.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited