better error for IP like 192.168.001.1 => 192.168.1.1

This commit is contained in:
Emmanuel Garette 2020-08-04 16:33:52 +02:00
parent 2d7729612b
commit 2f125cfc8c
1 changed files with 3 additions and 1 deletions

View File

@ -62,7 +62,9 @@ class IPOption(StrOption):
def _validate_ip(self, value): def _validate_ip(self, value):
try: try:
ip_address(value) new_value = str(ip_address(value))
if value != new_value:
raise ValueError(f'should be {new_value}')
except ValueError: except ValueError:
raise ValueError() raise ValueError()