multipleOf : Number
multipleOf
NumberA numeric instance is valid only if division by this keyword’s value results in an integer.
Value | This keyword must be set to a number that is greater than zero |
---|---|
Kind | Assertion |
Applies To | Number |
Dialect | 2020-12 |
Changed In | None |
Introduced In | Draft 4 |
Vocabulary | Validation |
Specification | https://json-schema.org/draft/2020-12/json-schema-validation.html#section-6.2.1 |
Metaschema | https://json-schema.org/draft/2020-12/meta/validation |
Official Tests | draft2020-12/multipleOf.json |
Default |
1
|
Annotation | None |
Affected By | None |
Affects | None |
Also See |
|
The multipleOf
keyword is used to specify that an instance must be a multiple of a given number. The value of this keyword must be strictly greater than zero.
- Validates if an instance is divisible by the specified number.
Examples
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"multipleOf": 5
}
10
8
-15
"foo"
multipleOf
only affects numeric instances and has no effect on other types of instances.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "number",
"multipleOf": 4.1
}
8.2
2
0
"foo"
multipleOf
only affects numeric instances and has no effect on other types of instances. However, the above instance failed due to thetype
constraint.