Skip to content

.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().

NumberValidator<N, O> min(N minValue, {String? message, MessageBuilder? messageBuilder})
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.

@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.

final age = l.int().min(18);
age.validate(input)+1-1
  1. valid: 18
  2. invalid: 17value must be greater than or equal to 18

On a double validator the limit is a double:

final ratio = l.double().min(0.5);
ratio.validate(input)+1-1
  1. valid: 0.75
  2. invalid: 0.25value must be greater than or equal to 0.5