def name_validator_with_changed_msg(val, context): """This is just a wrapper function around the validator.name_validator function. The wrapper function just changes the message in case the name_match doesn't match. The only purpose for still calling that function here is to keep the link visible and in case of a ckan upgrade to still be able to raise any new Invalid exceptions """ try: return name_validator(val, context) except Invalid as invalid: if val in ['new', 'edit', 'search']: raise Invalid(_('That name cannot be used')) if len(val) < 2: raise Invalid(_('Name must be at least %s characters long') % 2) if len(val) > PACKAGE_NAME_MAX_LENGTH: raise Invalid(_('Name must be a maximum of %i characters long') % \ PACKAGE_NAME_MAX_LENGTH) if not name_match.match(val): raise Invalid(_('Username should be lowercase letters and/or numbers and/or these symbols: -_')) raise invalid