Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 0de2636

Browse files
committed
Update for new semantics of exclusiveMin/Max
1 parent 918bff3 commit 0de2636

File tree

1 file changed

+43
-25
lines changed

1 file changed

+43
-25
lines changed

source/reference/numeric.rst

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -152,24 +152,22 @@ Ranges of numbers are specified using a combination of the
152152
``minimum`` and ``maximum`` keywords (or ``exclusiveMinimum`` and
153153
``exclusiveMaximum`` for expressing exclusive range).
154154

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

167165
.. schema_example::
168166

169167
{
170168
"type": "number",
171169
"minimum": 0,
172-
"maximum": 100
170+
"exclusiveMaximum": 100
173171
}
174172
--X
175173
// Less than ``minimum``:
@@ -182,21 +180,41 @@ Ranges of numbers are specified using a combination of the
182180
--
183181
99
184182
--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
198183
// ``exclusiveMaximum`` is exclusive, so 100 is not valid:
199184
100
200185
--X
201186
// Greater than ``maximum``:
202187
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:
217+
100
218+
--X
219+
// Greater than ``maximum``:
220+
101

0 commit comments

Comments
 (0)