.finite()
Passes when value.isFinite is true. NaN, double.infinity and double.negativeInfinity are doubles, so they pass l.double() and l.num() unless .finite() is present. jsonDecode never produces them, but values computed in Dart can.
Signature
Section titled “Signature”NumberValidator<N, O> finite({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 notFinite. Default message: value must be a finite number. value is replaced by the field name when there is one.
Code generation
Section titled “Code generation”No annotation adds .finite() yet. Apply it to the generated schema’s field by hand if you need it, or check it in a @WithCustomValidator.
Example
Section titled “Example”final price = l.double().finite();bool isFinite(double value) => value.isFinite;
@WithCustomValidator(isFinite, message: 'must be finite') required double price,price.validate(input)+1-2- valid:
19.99 - invalid:
double.nan - invalid:
double.infinity
Without .finite():
truetrue