You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 3, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: source/reference/numeric.rst
+43-25Lines changed: 43 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -152,24 +152,22 @@ Ranges of numbers are specified using a combination of the
152
152
``minimum`` and ``maximum`` keywords (or ``exclusiveMinimum`` and
153
153
``exclusiveMaximum`` for expressing exclusive range).
154
154
155
-
- ``minimum`` specifies an inclusive lower limit for a numeric instance,
156
-
i.e., :math:`x \ge\mathrm{min}`.
157
-
158
-
- ``exclusiveMinimum`` specifies an exclusive lower limit for a numeric instance,
159
-
i.e., :math:`x > \mathrm{min}`.
160
-
161
-
- ``maximum`` specifies an inclusive upper limit for a numeric instance,
162
-
i.e., :math:`x \le\mathrm{max}`.
163
-
164
-
- ``exclusiveMaximum`` specifies an exclusive upper limit for a numeric
165
-
instance. , i.e., :math:`x < \mathrm{max}`.
155
+
If *x* is the value being validated, the following must hold true:
156
+
157
+
- *x* ≥ ``minimum``
158
+
- *x* > ``exclusiveMinimum``
159
+
- *x* ≤ ``maximum``
160
+
- *x* < ``exclusiveMaximum``
161
+
162
+
While you can specify both of ``minimum`` and ``exclusiveMinimum`` or both of
163
+
``maximum`` and ``exclusiveMinimum``, it doesn't really make sense to do so.
166
164
167
165
.. schema_example::
168
166
169
167
{
170
168
"type": "number",
171
169
"minimum": 0,
172
-
"maximum": 100
170
+
"exclusiveMaximum": 100
173
171
}
174
172
--X
175
173
// Less than ``minimum``:
@@ -182,21 +180,41 @@ Ranges of numbers are specified using a combination of the
182
180
--
183
181
99
184
182
--X
185
-
// ``maximum`` is inclusive, so 100 is valid:
186
-
100
187
-
--X
188
-
// Greater than ``maximum``:
189
-
101
190
-
191
-
.. schema_example::
192
-
{
193
-
"type": "number",
194
-
"minimum": 0,
195
-
"exclusiveMaximum": 100
196
-
}
197
-
--X
198
183
// ``exclusiveMaximum`` is exclusive, so 100 is not valid:
199
184
100
200
185
--X
201
186
// Greater than ``maximum``:
202
187
101
188
+
189
+
.. language_specific::
190
+
191
+
--Draft 4
192
+
In JSON Schema Draft 4, ``exclusiveMinimum`` and ``exclusiveMaximum`` work differently. There they are boolean values, that indicate whether ``minimum`` and ``maximum`` are exclusive of the value. For example:
193
+
194
+
- if ``exclusiveMinimum`` is ``false``, *x* ≥ ``minimum``.
195
+
- if ``exclusiveMinimum`` is ``true``, *x* > ``minimum``.
196
+
197
+
.. schema_example:: 4
198
+
199
+
{
200
+
"type": "number",
201
+
"minimum": 0,
202
+
"maximum": 100,
203
+
"exclusiveMaximum": true
204
+
}
205
+
--X
206
+
// Less than ``minimum``:
207
+
-1
208
+
--
209
+
// ``exclusiveMinimum`` was not specified, so 0 is included:
210
+
0
211
+
--
212
+
10
213
+
--
214
+
99
215
+
--X
216
+
// ``exclusiveMaximum`` is ``true``, so 100 is not included:
0 commit comments