MaxValueValidator class

A validator that checks if the value is equal or less than maxValue.

The MaxValueValidator can be used with FieldControllers holding values of types int or double. It ensures that the value is equal or less than maxValue.

If the value is null it is treated as valid by default.

Properties

  • maxValue: The maximun allowed for the value.
  • message: An optional custom error message to display when invalid.

Example

FieldController<int> field = FieldController(
  key: 'name',
  validators:[MaxValueValidator(6)],
);

// If field.value = 7, validation fails.
// If field.value = 6, validation passes.

See also

Inheritance

Constructors

MaxValueValidator.new(num maxValue, {String? message})

Properties

hashCode int
The hash code for this object.
no setterinherited
maxValue num
The maximun allowed for the value.
final
message String?
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

call(FieldController<num> controller) ValidationResult
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onValidate(FieldController<num> controller) ValidationResult
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited