Number & Integer

Represents JS primitive type number.

{
    "type": "number"
}

Represents integer type. Since JS doesn't have integer it's represented as JS primitive type number.

{
    "type": "integer"
}

Options

minimum

The value of "minimum" MUST be a number, representing an inclusive lower limit for a numeric instance. If the instance is a number, then this keyword validates only if the instance is greater than or exactly equal to "minimum".

maximum

The value of "maximum" MUST be a number, representing an inclusive upper limit for a numeric instance. If the instance is a number, then this keyword validates only if the instance is less than or exactly equal to "maximum".

Options for only number type

even

The value of "even" MUST be a boolean, representing the number must be even.

odd

The value of "odd" MUST be a boolean, representing the number must be odd.

Options for only number type

exclusiveMinimum

The value of "exclusiveMinimum" MUST be number, representing an exclusive lower limit for a numeric instance. If the instance is a number, then the instance is valid only if it has a value strictly greater than (not equal to) "exclusiveMinimum".

exclusiveMaximum

The value of "exclusiveMaximum" MUST be number, representing an exclusive upper limit for a numeric instance. If the instance is a number, then the instance is valid only if it has a value strictly less than (not equal to) "exclusiveMaximum".

minDecimalDigits

The minimum number of digits after the decimal point. Default is 0.

maxDecimalDigits

The maximum number of digits after the decimal point. Default is unlimited. Note: JS uses float so you do not have unlimited fractions.

Examples

{
    'type'            : 'number',
    'required'        : true,
    'default'         : 1,
    'minDecimalDigits': 3,
    'maxDecimalDigits': 3,
}

Last updated

Was this helpful?