validator: Replace InvalidInput exception w/ InvalidName

Cases like empty names already generate the more descriptive
message:
  "ERROR: An invalid 'name' value was provided."

This makes the error for an excessively long name report the
same instead of the more generic:
  "ERROR: Invalid input received:"

Change-Id: I59cba80d3919c570d286c1c90adeb30f8507ff4f
This commit is contained in:
Eric Harney 2020-02-19 12:43:53 -05:00
parent c9815e27e0
commit 9cc1499924
2 changed files with 2 additions and 2 deletions

View File

@ -157,7 +157,7 @@ def _validate_name_skip_leading_trailing_spaces(param_value):
raise exception.InvalidName(reason=msg)
elif len(param_value) > 255:
msg = _("The 'name' can not be greater than 255 characters.")
raise exception.InvalidInput(reason=msg)
raise exception.InvalidName(reason=msg)
return True

View File

@ -481,7 +481,7 @@ class QoSSpecManageApiTest(test.TestCase):
@ddt.data(({'name': None}, exception.ValidationError),
({'name': ''}, exception.ValidationError),
({'name': ' '}, exception.ValidationError),
({'name': 'n' * 256}, exception.InvalidInput))
({'name': 'n' * 256}, exception.ValidationError))
@ddt.unpack
def test_create_qos_with_invalid_spec_name(self, value, exception_class):
body = {'qos_specs': value}