Skip to main content
JSON Schema provides several keywords for validating numeric instances (both number and integer types).

multipleOf

Validates that a number is a multiple of a specified value.

Syntax

The value must be a number strictly greater than 0.

Validation Rules

A numeric instance is valid only if division by the multipleOf value results in an integer.

Examples

Integer Multiples

Valid instances:
Invalid instances:

Decimal Multiples

Valid instances:
Invalid instances:

Even Numbers

Valid instances:
Invalid instances:

minimum

Specifies an inclusive lower bound for a numeric value.

Syntax

The value must be a number.

Validation Rules

If the instance is a number, it validates only if the value is greater than or equal to minimum.

Examples

Valid instances:
Invalid instances:

maximum

Specifies an inclusive upper bound for a numeric value.

Syntax

The value must be a number.

Validation Rules

If the instance is a number, it validates only if the value is less than or equal to maximum.

Examples

Valid instances:
Invalid instances:

exclusiveMinimum

Specifies an exclusive lower bound for a numeric value.

Syntax

The value must be a number.

Validation Rules

If the instance is a number, it is valid only if the value is strictly greater than (not equal to) exclusiveMinimum.

Examples

Valid instances:
Invalid instances:

exclusiveMaximum

Specifies an exclusive upper bound for a numeric value.

Syntax

The value must be a number.

Validation Rules

If the instance is a number, it is valid only if the value is strictly less than (not equal to) exclusiveMaximum.

Examples

Valid instances:
Invalid instances:

Combining Numeric Keywords

Multiple numeric validation keywords can be used together to define precise ranges and constraints.

Age Range

Valid instances:

Percentage

This validates percentages with up to 2 decimal places:

Temperature Range (exclusive bounds)

This validates temperatures above absolute zero up to 1000:
Invalid:

Price Validation

This validates positive prices with cent precision:
Invalid:

Score Range

Valid instances (scores in increments of 5):
Invalid instances:

Positive Integer

Valid instances:
Invalid instances:

Open Range

This validates numbers in the open interval (0, 1):
Invalid:

Precision Considerations

JSON Schema allows numbers with arbitrary precision. However, be aware that:
  • Floating-point arithmetic may introduce rounding errors
  • Programming language limitations may affect precision
  • When using multipleOf with decimal values, consider potential floating-point representation issues
For financial calculations, consider using integer types with an implied decimal point (e.g., storing cents as integers).