fix: message error improvment
This commit is contained in:
parent
4cba819e0a
commit
6181b728ad
3 changed files with 16 additions and 9 deletions
|
@ -76,14 +76,20 @@ class DomainnameOption(StrOption):
|
||||||
regexp = r"((?!-)[a-z0-9-]{{{1},{0}}}\.){{{1},}}[a-z0-9-]{{1,{0}}}".format(
|
regexp = r"((?!-)[a-z0-9-]{{{1},{0}}}\.){{{1},}}[a-z0-9-]{{1,{0}}}".format(
|
||||||
self._get_len(type), min_time
|
self._get_len(type), min_time
|
||||||
)
|
)
|
||||||
|
msg = _(
|
||||||
|
'must start with lowercase characters followed by lowercase characters, number, "-" and "." characters are allowed'
|
||||||
|
)
|
||||||
|
msg_warning = _(
|
||||||
|
'must start with lowercase characters followed by lowercase characters, number, "-" and "." characters are recommanded'
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
regexp = r"((?!-)[a-z0-9-]{{1,{0}}})".format(self._get_len(type))
|
regexp = r"((?!-)[a-z0-9-]{{1,{0}}})".format(self._get_len(type))
|
||||||
msg = _(
|
msg = _(
|
||||||
'must start with lowercase characters followed by lowercase characters, number, "-" and "." characters are allowed'
|
'must start with lowercase characters followed by lowercase characters, number and "-" characters are allowed'
|
||||||
)
|
)
|
||||||
msg_warning = _(
|
msg_warning = _(
|
||||||
'must start with lowercase characters followed by lowercase characters, number, "-" and "." characters are recommanded'
|
'must start with lowercase characters followed by lowercase characters, number and "-" characters are recommanded'
|
||||||
)
|
)
|
||||||
if allow_ip:
|
if allow_ip:
|
||||||
msg = _("could be a IP, otherwise {}").format(msg)
|
msg = _("could be a IP, otherwise {}").format(msg)
|
||||||
msg_warning = _("could be a IP, otherwise {}").format(msg_warning)
|
msg_warning = _("could be a IP, otherwise {}").format(msg_warning)
|
||||||
|
|
|
@ -74,8 +74,9 @@ class FilenameOption(StrOption):
|
||||||
if not found and "directory" in types and file.is_dir():
|
if not found and "directory" in types and file.is_dir():
|
||||||
found = True
|
found = True
|
||||||
if not found:
|
if not found:
|
||||||
|
translated_types = [{"file": _("file"), "directory": _("directory")}.get(typ) for typ in types]
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
_('cannot find {0} "{1}"').format(
|
_('cannot find this {0}').format(
|
||||||
display_list(types, separator="or"), value
|
display_list(translated_types, separator="or"), value
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -38,7 +38,7 @@ class StrOption(Option):
|
||||||
) -> None:
|
) -> None:
|
||||||
"""validation"""
|
"""validation"""
|
||||||
if not isinstance(value, str):
|
if not isinstance(value, str):
|
||||||
raise ValueError()
|
raise ValueError(_('which is not a string'))
|
||||||
|
|
||||||
|
|
||||||
class RegexpOption(StrOption):
|
class RegexpOption(StrOption):
|
||||||
|
|
Loading…
Reference in a new issue