@@ -149,46 +149,78 @@ Range
149
149
'''''
150
150
151
151
Ranges of numbers are specified using a combination of the
152
- ``minimum ``, ``maximum ``, ``exclusiveMinimum `` and
153
- ``exclusiveMaximum `` keywords .
152
+ ``minimum `` and ``maximum `` keywords, (or ``exclusiveMinimum `` and
153
+ ``exclusiveMaximum `` for expressing exclusive range) .
154
154
155
- - `` minimum `` specifies a minimum numeric value.
155
+ If * x * is the value being validated, the following must hold true:
156
156
157
- - ``exclusiveMinimum `` is a boolean. When ``true ``, it indicates that
158
- the range excludes the minimum value, i.e., :math: `x >
159
- \mathrm {min}`. When ``false `` (or not included), it indicates that
160
- the range includes the minimum value, i.e., :math: `x \ge
161
- \mathrm {min}`.
157
+ - *x * ≥ ``minimum ``
158
+ - *x * > ``exclusiveMinimum ``
159
+ - *x * ≤ ``maximum ``
160
+ - *x * < ``exclusiveMaximum ``
162
161
163
- - ``maximum `` specifies a maximum numeric value.
164
-
165
- - ``exclusiveMaximum `` is a boolean. When ``true ``, it indicates that
166
- the range excludes the maximum value, i.e., :math: `x <
167
- \mathrm {max}`. When ``false `` (or not included), it indicates that
168
- the range includes the maximum value, i.e., :math: `x \le
169
- \mathrm {max}`.
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.
170
164
171
165
.. schema_example ::
172
166
173
167
{
174
168
"type": "number",
175
169
"minimum": 0,
176
- "maximum": 100,
177
- "exclusiveMaximum": true
170
+ "exclusiveMaximum": 100
178
171
}
179
172
--X
180
173
// Less than ``minimum ``:
181
174
-1
182
175
--
183
- // ``exclusiveMinimum `` was not specified , so 0 is included :
176
+ // ``minimum `` is inclusive , so 0 is valid :
184
177
0
185
178
--
186
179
10
187
180
--
188
181
99
189
182
--X
190
- // ``exclusiveMaximum `` is `` true `` , so 100 is not included :
183
+ // ``exclusiveMaximum `` is exclusive , so 100 is not valid :
191
184
100
192
185
--X
193
186
// Greater than ``maximum ``:
194
187
101
188
+
189
+ .. language_specific ::
190
+
191
+ --Draft 4
192
+ In JSON Schema Draft 4, ``exclusiveMinimum `` and ``exclusiveMaximum `` work
193
+ differently. There they are boolean values, that indicate whether
194
+ ``minimum `` and ``maximum `` are exclusive of the value. For example:
195
+
196
+ - if ``exclusiveMinimum `` is ``false ``, *x * ≥ ``minimum ``.
197
+ - if ``exclusiveMinimum `` is ``true ``, *x * > ``minimum ``.
198
+
199
+ This was changed to have better keyword independence.
200
+
201
+ Here is an example using the older Draft 4 convention:
202
+
203
+ .. schema_example :: 4
204
+
205
+ {
206
+ "type": "number",
207
+ "minimum": 0,
208
+ "maximum": 100,
209
+ "exclusiveMaximum": true
210
+ }
211
+ --X
212
+ // Less than ``minimum ``:
213
+ -1
214
+ --
215
+ // ``exclusiveMinimum `` was not specified, so 0 is included:
216
+ 0
217
+ --
218
+ 10
219
+ --
220
+ 99
221
+ --X
222
+ // ``exclusiveMaximum `` is ``true ``, so 100 is not included:
223
+ 100
224
+ --X
225
+ // Greater than ``maximum ``:
226
+ 101
0 commit comments