ValidateNumber extension

Validates a number against the constraints a schema declares for it.

validate is the sugar the generator emits: one call carrying every bound the schema sets, each argument omitted when it doesn't. It just forwards to the single-rule methods below, which are equally usable on their own.

on

Methods

validate({num? min, num? max, num? exclusiveMin, num? exclusiveMax, num? multipleOf}) → void

Available on num, provided by the ValidateNumber extension

validateEnumValues(List<num> enumValues) → void

Available on num, provided by the ValidateNumber extension

Validates that the value is one of enumValues — the members of a nameless integer enum, which is generated as a newtype over int. This is its own call rather than a validate argument: an int enum never also carries range bounds, so membership is the only rule. Unlike the range checks, an out-of-set value is a parse failure (the wire carried a value the type does not name), so it throws FormatException to match how a generated fromJson reports malformed input.
validateExclusiveMaximum(num maximum) → void

Available on num, provided by the ValidateNumber extension

validateExclusiveMinimum(num minimum) → void

Available on num, provided by the ValidateNumber extension

validateMaximum(num maximum) → void

Available on num, provided by the ValidateNumber extension

validateMinimum(num minimum) → void

Available on num, provided by the ValidateNumber extension

validateMultipleOf(num multiple) → void

Available on num, provided by the ValidateNumber extension