Skip to content

Commit 58cba37

Browse files
committedSep 12, 2018
horejsek#21 Fix code generation with regex patterns
1 parent 88a3941 commit 58cba37

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed
 

‎CHANGELOG.txt

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
=== 2.1 (2018-09-12) ===
2+
3+
* Fix code generation with regex patterns
4+
5+
16
=== 2.0 (2018-09-07) ===
27

38
* Support of draft-06

‎fastjsonschema/generator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def global_state_code(self):
8585
"""
8686
self._generate_func_code()
8787

88-
if self._compile_regexps:
88+
if not self._compile_regexps:
8989
return '\n'.join(
9090
[
9191
'from fastjsonschema import JsonSchemaException',

‎fastjsonschema/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '2.0'
1+
VERSION = '2.1'

‎tests/test_compile_to_code.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,20 @@ def test_compile_to_code():
99
'properties': {
1010
'a': {'type': 'string'},
1111
'b': {'type': 'integer'},
12+
'c': {'format': 'hostname'},
1213
}
1314
})
1415
if not os.path.isdir('temp'):
1516
os.makedirs('temp')
1617
with open('temp/schema.py', 'w') as f:
1718
f.write(code)
1819
from temp.schema import validate
19-
assert validate({'a': 'a', 'b': 1}) == {'a': 'a', 'b': 1}
20+
assert validate({
21+
'a': 'a',
22+
'b': 1,
23+
'c': 'example.com',
24+
}) == {
25+
'a': 'a',
26+
'b': 1,
27+
'c': 'example.com',
28+
}

0 commit comments

Comments
 (0)
Please sign in to comment.