Numbers
This schema snippet shows how to define a schema with integer and number properties and demonstrates how to use the minimum
, maximum
and multipleOf
validation keywords to constrain the values that the user can enter.
Note that in Dynamic Content, integers must be whole numbers. For example 1.0 is not a valid integer.
The exclusiveMaximum
and exclusiveMinimum
validation keywords are not currently supported.
Pre-requisites
This is a self contained schema that just uses standard JSON Schema property types and validations.
How to use
You can change the validation of each property to meet your own requirements.
Integer and number snippet
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://schema-examples.com/numbers",
"title": "Title",
"description": "Description",
"allOf": [
{
"$ref": "http://bigcontent.io/cms/schema/v1/core#/definitions/content"
}
],
"type": "object",
"properties": {
"integerWithRange": {
"title": "Simple integer",
"description": "An integer between 1 and 15",
"type": "integer",
"minimum": 1,
"maximum": 15
},
"integerMultipleOf10": {
"title": "Integer multiple",
"description": "An integer between 1 and 100. A multiple of 10",
"type": "integer",
"minimum": 10,
"maximum": 100,
"multipleOf": 10
},
"numberWithRange": {
"title": "Number with range",
"description": "A number between 35.2 and 39.6",
"type": "number",
"minimum": 35.2,
"maximum": 39.6
},
"numberWithNegativeMin": {
"title": "Number with negative min",
"description": "A number that must be >= -25",
"type": "number",
"minimum": -25
}
},
"propertyOrder": []
}
Content form preview
An example of creating a content item using a content type registered from the numbers example schema is shown in the image below.