better message error

This commit is contained in:
egarette@silique.fr 2023-01-24 22:37:05 +01:00
parent 302be618ce
commit 477b0a2da1

View file

@ -64,7 +64,7 @@ class IPOption(StrOption):
try:
new_value = str(ip_address(value))
if value != new_value:
raise ValueError(f'should be {new_value}')
raise ValueError(_(f'should be {new_value}'))
except ValueError:
raise ValueError()
@ -72,6 +72,8 @@ class IPOption(StrOption):
value: str) -> None:
super().validate(value)
if self.impl_get_extra('_cidr'):
if '/' not in value:
raise ValueError(_('CIDR address must have a "/"'))
self._validate_cidr(value)
else:
self._validate_ip(value)