Skip to content

Commit

Permalink
Improved regexp for ipv4 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 524b9e8 commit bb03f7c
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Fixed that everything with empty `not` is invalid
* Improved regexp for email format to comfort test suite
* Improved regexp for date format to comfort test suite
* Improved regexp for ipv4 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 @@ -29,7 +29,7 @@ class CodeGeneratorDraft04(CodeGenerator):
'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',
'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',
'ipv4': r'^((25[0-5]|2[0-4][0-9]|1?[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]|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fa-f]{1,4})?::(?:[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',
'uri': r'^\w+:(\/?\/?)[^\s]+\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 @@ -21,7 +21,6 @@ def pytest_generate_tests(metafunc):
'enum.json',

# TODO: fix formats
'ipv4.json',
'ipv6.json',
'time.json',
'format.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 @@ -21,7 +21,6 @@ def pytest_generate_tests(metafunc):
'enum.json',

# TODO: fix formats
'ipv4.json',
'ipv6.json',
'time.json',
'format.json',
Expand Down
2 changes: 1 addition & 1 deletion tests/json_schema/test_draft07.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def pytest_generate_tests(metafunc):
'enum.json',

# TODO: fix formats
'ipv4.json',
#'ipv4.json',
'ipv6.json',
'time.json',
'format.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 @@ -24,7 +24,6 @@ def pytest_generate_tests(metafunc):
'enum.json',

# TODO: fix formats
'ipv4.json',
'ipv6.json',
'time.json',
'format.json',
Expand Down

0 comments on commit bb03f7c

Please sign in to comment.