.min()
Passes when the value is at least minValue. The limit has the validator’s number type: int on l.int(), double on l.double(), num on l.num().
Signature
Section titled “Signature”NumberValidator<N, O> min(N minValue, {String? message, MessageBuilder? messageBuilder})Parameters
Section titled “Parameters”| Parameter | Type | Meaning |
|---|---|---|
minValue |
N |
The smallest accepted value, inclusive. params['min']. |
message |
String? |
Replaces the default error message. |
messageBuilder |
MessageBuilder? |
Builds the message from the issue. message wins when both are given. See Message builders. |
Code tooSmall. Default message: value must be greater than or equal to 18, with the limit as given. value is replaced by the field name when there is one.
Code generation
Section titled “Code generation”@HasMin(n) on an int, double or num field. n is a num; a fractional value on an int field fails generation. On a String field the same annotation is a minimum length.
Example
Section titled “Example”final age = l.int().min(18);@HasMin(18) required int age, // l.int().min(18).required()@HasMin(0.5) required double ratio, // l.double().min(0.5).required()@HasMin(0) required num total, // l.num().min(0).required()age.validate(input)+1-1- valid:
18 - invalid:
17
On a double validator the limit is a double:
final ratio = l.double().min(0.5);ratio.validate(input)+1-1- valid:
0.75 - invalid:
0.25