.min()
Passes when value.length is at least minLength. Throws ArgumentError when the validator is built with a negative length.
Signature
Section titled “Signature”StringValidator<O> min(int minLength, {String? message, MessageBuilder? messageBuilder})Parameters
Section titled “Parameters”| Parameter | Type | Meaning |
|---|---|---|
minLength |
int |
The smallest accepted length. 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 tooShort. Default message: value must be at least 8 characters long; 1 character long for a limit of 1. value is replaced by the field name when there is one.
Code generation
Section titled “Code generation”@HasMin(n) on a String field. On a number field the same annotation means a minimum value. Put the annotation on the constructor parameter or the field.
Example
Section titled “Example”final password = l.string().min(8);@HasMin(8) required String password, // l.string().min(8).required()password.validate(input)+1-1- valid:
'hunter2hunter2' - invalid:
'abc'