We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4afa243 commit c056d64Copy full SHA for c056d64
2 files changed
tests/test_ipv4.py
@@ -19,6 +19,7 @@ def test_returns_true_on_valid_ipv4_address(address):
19
('1278.0.0.1',),
20
('127.0.0.abc',),
21
('900.200.100.75',),
22
+ ('0127.0.0.1',),
23
])
24
def test_returns_failed_validation_on_invalid_ipv4_address(address):
25
assert isinstance(ipv4(address), ValidationFailure)
validators/ip_address.py
@@ -23,8 +23,12 @@ def ipv4(value):
:param value: IP address string to validate
"""
26
- groups = value.split('.')
27
- if len(groups) != 4 or any(not x.isdigit() for x in groups):
+ groups = value.split(".")
+ if (
28
+ len(groups) != 4
29
+ or any(not x.isdigit() for x in groups)
30
+ or any(len(x) > 3 for x in groups)
31
+ ):
32
return False
33
return all(0 <= int(part) < 256 for part in groups)
34
0 commit comments