Skip to content

Commit

Permalink
Improved regexp for email format to comfort test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
horejsek committed Jun 16, 2024
1 parent 7f85877 commit 952c501
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Fixed detecting when infinity is reached with multipleOf
* Fixed that min/max items/lenght/properties can be float
* Fixed that everything with empty `not` is invalid
* Improved regexp for email format to comfort test suite

=== 2.20.0 (2024-06-15)

Expand Down
2 changes: 1 addition & 1 deletion fastjsonschema/draft04.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CodeGeneratorDraft04(CodeGenerator):
# library. Some regexps are not 100% precise but good enough, fast and without dependencies.
FORMAT_REGEXS = {
'date-time': r'^\d{4}-[01]\d-[0-3]\d(t|T)[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:[+-][0-2]\d:[0-5]\d|[+-][0-2]\d[0-5]\d|z|Z)\Z',
'email': r'^[^@]+@[^@]+\.[^@]+\Z',
'email': r'^(?!.*\.\..*@)[^@.][^@]*(?<!\.)@[^@]+\.[^@]+\Z',
'hostname': r'^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]{0,61}[A-Za-z0-9])\Z',
'ipv4': r'^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\Z',
'ipv6': r'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9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0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)\Z',
Expand Down
1 change: 0 additions & 1 deletion tests/json_schema/test_draft04.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def pytest_generate_tests(metafunc):
'enum.json',

# TODO: fix formats
'email.json',
'date-time.json',
'date.json',
'ipv4.json',
Expand Down
1 change: 0 additions & 1 deletion tests/json_schema/test_draft06.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def pytest_generate_tests(metafunc):
'enum.json',

# TODO: fix formats
'email.json',
'date-time.json',
'date.json',
'ipv4.json',
Expand Down
1 change: 0 additions & 1 deletion tests/json_schema/test_draft07.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def pytest_generate_tests(metafunc):
'enum.json',

# TODO: fix formats
'email.json',
'date-time.json',
'date.json',
'ipv4.json',
Expand Down
1 change: 0 additions & 1 deletion tests/json_schema/test_draft2019.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def pytest_generate_tests(metafunc):
'enum.json',

# TODO: fix formats
'email.json',
'date-time.json',
'date.json',
'ipv4.json',
Expand Down

0 comments on commit 952c501

Please sign in to comment.