Skip to content

Commit bb03f7c

Browse files
committed
Improved regexp for ipv4 format to comfort test suite
1 parent 524b9e8 commit bb03f7c

File tree

6 files changed

+3
-5
lines changed

6 files changed

+3
-5
lines changed

CHANGELOG.txt

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Fixed that everything with empty `not` is invalid
77
* Improved regexp for email format to comfort test suite
88
* Improved regexp for date format to comfort test suite
9+
* Improved regexp for ipv4 format to comfort test suite
910

1011
=== 2.20.0 (2024-06-15)
1112

fastjsonschema/draft04.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class CodeGeneratorDraft04(CodeGenerator):
2929
'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',
3030
'email': r'^(?!.*\.\..*@)[^@.][^@]*(?<!\.)@[^@]+\.[^@]+\Z',
3131
'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',
32-
'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',
32+
'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',
3333
'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-9A-Fa-f]{1,4}:){5}(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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',
3434
'uri': r'^\w+:(\/?\/?)[^\s]+\Z',
3535
}

tests/json_schema/test_draft04.py

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def pytest_generate_tests(metafunc):
2121
'enum.json',
2222

2323
# TODO: fix formats
24-
'ipv4.json',
2524
'ipv6.json',
2625
'time.json',
2726
'format.json',

tests/json_schema/test_draft06.py

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ def pytest_generate_tests(metafunc):
2121
'enum.json',
2222

2323
# TODO: fix formats
24-
'ipv4.json',
2524
'ipv6.json',
2625
'time.json',
2726
'format.json',

tests/json_schema/test_draft07.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def pytest_generate_tests(metafunc):
2424
'enum.json',
2525

2626
# TODO: fix formats
27-
'ipv4.json',
27+
#'ipv4.json',
2828
'ipv6.json',
2929
'time.json',
3030
'format.json',

tests/json_schema/test_draft2019.py

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def pytest_generate_tests(metafunc):
2424
'enum.json',
2525

2626
# TODO: fix formats
27-
'ipv4.json',
2827
'ipv6.json',
2928
'time.json',
3029
'format.json',

0 commit comments

Comments
 (0)