multipleOf : Number
multipleOf
NumberA numeric instance is valid only if division by this keyword’s value results in an integer.
Kind | Assertion |
---|---|
Applies To | Number |
Dialect | 2020-12 |
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 |
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.
- Applicable only to
number
andinteger
type. - Validates if an instance is divisible by the specified number.
- Setting
multipleOf
to 0 is not valid.
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.