fix(validators): fixed improved error message on user group validators

This commit is contained in:
RhodeCode Admin 2024-01-15 14:33:34 +01:00
parent 49911056f3
commit 6437db69cd

View file

@ -164,8 +164,8 @@ def ValidUsername(localizer, edit=False, old_data=None):
_('Username "%(username)s" is forbidden'),
'invalid_username':
_('Username may only contain alphanumeric characters '
'underscores, periods or dashes and must begin with '
'alphanumeric character or underscore')
'underscores, periods or dashes and must begin with '
'alphanumeric character or underscore')
}
def _validate_python(self, value, state):
@ -223,7 +223,7 @@ def ValidUserGroup(localizer, edit=False, old_data=None):
'invalid_group': _('Invalid user group name'),
'group_exist': _('User group `%(usergroup)s` already exists'),
'invalid_usergroup_name':
_('user group name may only contain alphanumeric '
_('User group name may only contain alphanumeric '
'characters underscores, periods or dashes and must begin '
'with alphanumeric character')
}
@ -231,9 +231,7 @@ def ValidUserGroup(localizer, edit=False, old_data=None):
def _validate_python(self, value, state):
if value in ['default']:
msg = M(self, 'invalid_group', state)
raise formencode.Invalid(
msg, value, state, error_dict={'users_group_name': msg}
)
raise formencode.Invalid(msg, value, state)
# check if group is unique
old_ugname = None
if edit:
@ -251,9 +249,7 @@ def ValidUserGroup(localizer, edit=False, old_data=None):
if re.match(r'^[a-zA-Z0-9]{1}[a-zA-Z0-9\-\_\.]+$', value) is None:
msg = M(self, 'invalid_usergroup_name', state)
raise formencode.Invalid(
msg, value, state, error_dict={'users_group_name': msg}
)
raise formencode.Invalid(msg, value, state)
return _validator