Skip to content

Commit 1444717

Browse files
committed
Improve error message for 'not'
1 parent 79f0e23 commit 1444717

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

fastjsonschema/draft04.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ def generate_not(self):
211211
return
212212
elif not not_definition:
213213
with self.l('if {}:', self._variable):
214-
self.exc('{name} must not be valid by not definition', rule='not')
214+
self.exc('{name} must NOT match a disallowed definition', rule='not')
215215
else:
216216
with self.l('try:', optimize=False):
217217
self.generate_func_code_block(not_definition, self._variable, self._variable_name)
218218
self.l('except JsonSchemaValueException: pass')
219219
with self.l('else:'):
220-
self.exc('{name} must not be valid by not definition', rule='not')
220+
self.exc('{name} must NOT match a disallowed definition', rule='not')
221221

222222
def generate_min_length(self):
223223
with self.l('if isinstance({variable}, str):'):

tests/test_common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def test_one_of_factorized(asserter, value, expected):
9191

9292

9393
@pytest.mark.parametrize('value, expected', [
94-
(0, JsonSchemaValueException('data must not be valid by not definition', value='{data}', name='data', definition='{definition}', rule='not')),
94+
(0, JsonSchemaValueException('data must NOT match a disallowed definition', value='{data}', name='data', definition='{definition}', rule='not')),
9595
(True, True),
9696
('abc', 'abc'),
9797
([], []),

tests/test_integration.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
),
9595
(
9696
[9, 'hello', [1], {'a': 'a', 'b': 'b', 'x': 'x'}, None, 5],
97-
JsonSchemaValueException('data[4] must not be valid by not definition', value=None, name='data[4]', definition=definition['items'][4], rule='not'),
97+
JsonSchemaValueException('data[4] must NOT match a disallowed definition', value=None, name='data[4]', definition=definition['items'][4], rule='not'),
9898
),
9999
(
100100
[9, 'hello', [1], {'a': 'a', 'b': 'b', 'x': 'x'}, 42, 15],

0 commit comments

Comments
 (0)