l.int()
Passes when the value is int. Returns an IntValidator, a NumberValidator<int, int?> with .min(), .max() and .finite(). On the VM, 42.0 is a double and fails. On the web every number is a JavaScript number, so 42.0 is int is true there. For JSON that may carry either form, use l.num().
Signature
Section titled “Signature”NumberValidator<int, int?> int({String? message, MessageBuilder? messageBuilder})Parameters
Section titled “Parameters”| Parameter | Type | Meaning |
|---|---|---|
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 invalidType. Default message: value must be an integer. value is replaced by the field name when there is one.
Code generation
Section titled “Code generation”An int parameter maps to l.int(). @HasMin(n) and @HasMax(n) add .min(n) and .max(n); a fractional n on an int field fails generation.
Example
Section titled “Example”final count = l.int();@HasMin(18) required int age, // l.int().min(18).required()count.validate(input)+1-2- valid:
42 - invalid:
42.0 - invalid:
'42'