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

View file

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