Validate.compare constructor
- Comparable? lessThan,
- Comparable? greaterThan,
- Comparable? equalTo,
- Comparable? greaterThanEqualTo,
- Comparable? lessThanEqualTo,
- bool onUpdate = true,
- bool onInsert = true,
A validator for comparing a value.
Values passing through validators of this type must be lessThan
,
greaterThan
, lessThanEqualTo
, equalTo
, or [greaterThanEqualTo
to the value provided for each argument.
Any argument not specified is not evaluated. A typical validator only uses one argument:
@Validate.compare(lessThan: 10.0)
double value;
All provided arguments are evaluated. Therefore, the following requires an input value to be between 6 and 10:
@Validate.compare(greaterThanEqualTo: 6, lessThanEqualTo: 10)
int value;
This validator can be used for String, double, int and DateTime properties.
When creating a validator for DateTime properties, the value for an argument is a String that will be parsed by DateTime.parse.
@Validate.compare(greaterThan: "2017-02-11T00:30:00Z")
DateTime date;
If onUpdate
is true (the default), this validation is run on update queries.
If onInsert
is true (the default), this validation is run on insert queries.
Implementation
const Validate.compare({
Comparable? lessThan,
Comparable? greaterThan,
Comparable? equalTo,
Comparable? greaterThanEqualTo,
Comparable? lessThanEqualTo,
bool onUpdate = true,
bool onInsert = true,
}) : this._(
lessThan: lessThan,
lessThanEqualTo: lessThanEqualTo,
greaterThan: greaterThan,
greaterThanEqualTo: greaterThanEqualTo,
equalTo: equalTo,
onUpdate: onUpdate,
onInsert: onInsert,
validator: ValidateType.comparison,
);