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(
|
||||
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:
|
||||
regexp = r"((?!-)[a-z0-9-]{{1,{0}}})".format(self._get_len(type))
|
||||
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'
|
||||
)
|
||||
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'
|
||||
)
|
||||
if allow_ip:
|
||||
msg = _("could be a IP, otherwise {}").format(msg)
|
||||
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():
|
||||
found = True
|
||||
if not found:
|
||||
translated_types = [{"file": _("file"), "directory": _("directory")}.get(typ) for typ in types]
|
||||
raise ValueError(
|
||||
_('cannot find {0} "{1}"').format(
|
||||
display_list(types, separator="or"), value
|
||||
_('cannot find this {0}').format(
|
||||
display_list(translated_types, separator="or"), value
|
||||
)
|
||||
)
|
||||
|
|
|
@ -38,7 +38,7 @@ class StrOption(Option):
|
|||
) -> None:
|
||||
"""validation"""
|
||||
if not isinstance(value, str):
|
||||
raise ValueError()
|
||||
raise ValueError(_('which is not a string'))
|
||||
|
||||
|
||||
class RegexpOption(StrOption):
|
||||
|
|
Loading…
Reference in a new issue