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.
{
  "multipleOf": 5
}

Validation Rules

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

Examples

Integer Multiples

{
  "type": "number",
  "multipleOf": 5
}
Valid instances:
0
5
10
-15
Invalid instances:
3
7
12

Decimal Multiples

{
  "type": "number",
  "multipleOf": 0.5
}
Valid instances:
0.5
1.0
2.5
-1.5
Invalid instances:
0.3
1.7
2.25

Even Numbers

{
  "type": "integer",
  "multipleOf": 2
}
Valid instances:
0
2
-4
100
Invalid instances:
1
3
-5

minimum

Specifies an inclusive lower bound for a numeric value.

Syntax

The value must be a number.
{
  "minimum": 0
}

Validation Rules

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

Examples

{
  "type": "number",
  "minimum": 0
}
Valid instances:
0
1
100.5
Invalid instances:
-1
-0.01
-100

maximum

Specifies an inclusive upper bound for a numeric value.

Syntax

The value must be a number.
{
  "maximum": 100
}

Validation Rules

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

Examples

{
  "type": "number",
  "maximum": 100
}
Valid instances:
0
50
100
Invalid instances:
100.1
101
200

exclusiveMinimum

Specifies an exclusive lower bound for a numeric value.

Syntax

The value must be a number.
{
  "exclusiveMinimum": 0
}

Validation Rules

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

Examples

{
  "type": "number",
  "exclusiveMinimum": 0
}
Valid instances:
0.01
1
100
Invalid instances:
0
-1
-0.01

exclusiveMaximum

Specifies an exclusive upper bound for a numeric value.

Syntax

The value must be a number.
{
  "exclusiveMaximum": 100
}

Validation Rules

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

Examples

{
  "type": "number",
  "exclusiveMaximum": 100
}
Valid instances:
99.99
50
0
Invalid instances:
100
100.01
200

Combining Numeric Keywords

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

Age Range

{
  "type": "integer",
  "minimum": 0,
  "maximum": 120
}
Valid instances:
0
25
120

Percentage

{
  "type": "number",
  "minimum": 0,
  "maximum": 100,
  "multipleOf": 0.01
}
This validates percentages with up to 2 decimal places:
0
50.5
99.99
100

Temperature Range (exclusive bounds)

{
  "type": "number",
  "exclusiveMinimum": -273.15,
  "maximum": 1000
}
This validates temperatures above absolute zero up to 1000:
-273.14
0
100.5
1000
Invalid:
-273.15  // Equal to exclusiveMinimum
1000.01  // Exceeds maximum

Price Validation

{
  "type": "number",
  "minimum": 0,
  "exclusiveMinimum": 0,
  "multipleOf": 0.01
}
This validates positive prices with cent precision:
0.01
9.99
100.00
Invalid:
0       // Not greater than exclusiveMinimum
-1      // Negative price
10.999  // Too many decimal places

Score Range

{
  "type": "integer",
  "minimum": 0,
  "maximum": 100,
  "multipleOf": 5
}
Valid instances (scores in increments of 5):
0
5
50
100
Invalid instances:
3
47
105

Positive Integer

{
  "type": "integer",
  "minimum": 1
}
Valid instances:
1
10
1000
Invalid instances:
0
-1
3.14

Open Range

{
  "type": "number",
  "exclusiveMinimum": 0,
  "exclusiveMaximum": 1
}
This validates numbers in the open interval (0, 1):
0.1
0.5
0.999
Invalid:
0
1

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).

Build docs developers (and LLMs) love