fix: better port validation with the value ''
This commit is contained in:
parent
379630fc38
commit
ebc9779173
2 changed files with 3 additions and 4 deletions
|
|
@ -352,6 +352,8 @@ def test_invalid_option():
|
|||
PortOption('a', '', allow_zero=False, allow_wellknown=False, allow_registred=False, allow_private=False)
|
||||
with raises(ValueError):
|
||||
PortOption('a', '', 'tcp:80')
|
||||
with raises(ValueError):
|
||||
PortOption('a', '', '')
|
||||
NetworkOption('a', '')
|
||||
with raises(ValueError):
|
||||
NetworkOption('a', '', 'string')
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@
|
|||
# ____________________________________________________________
|
||||
"""PortOption
|
||||
"""
|
||||
import re
|
||||
|
||||
from ..i18n import _
|
||||
from .stroption import StrOption
|
||||
|
||||
|
|
@ -38,7 +36,6 @@ class PortOption(StrOption):
|
|||
"""
|
||||
|
||||
__slots__ = tuple()
|
||||
port_re = re.compile(r"^[0-9]*$")
|
||||
_type = "port"
|
||||
|
||||
def __init__(
|
||||
|
|
@ -104,7 +101,7 @@ class PortOption(StrOption):
|
|||
value = [value]
|
||||
|
||||
for val in value:
|
||||
if not self.port_re.search(val):
|
||||
if not val.isdecimal():
|
||||
raise ValueError()
|
||||
|
||||
def second_level_validation(self, value: str, warnings_only: bool) -> None:
|
||||
|
|
|
|||
Loading…
Reference in a new issue