NegativeValidator<T extends num> class
A validator that ensures a given num value is negative.
The NegativeValidator checks whether the provided value is strictly less than zero.
If the value is valid, the validation passes (null is returned).
Otherwise, it returns the provided error message.
Example
final validator = NegativeValidator(message: 'Value must be negative');
print(validator.validate(-5)); // null (valid)
print(validator.validate(-0.1)); // null (valid)
print(validator.validate(0)); // 'Value must be negative' (invalid)
print(validator.validate(5)); // 'Value must be negative' (invalid)
print(validator.validate(null)); // 'Value must be negative' (invalid)
- Inheritance
-
- Object
- Validator<
T> - ValidatorWithMessage<
T> - NegativeValidator
Constructors
- NegativeValidator({required String message})
-
Creates a
NegativeValidatorthat ensures values are negative.
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
validate(
covariant T value) → String? -
Validates the provided
value.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited