Validation error

Validation errors indicate that a request provided by the client was incorrect an contain detailed information about the errors for each request property. Below is a common validation error response.

{
  "type": "https://docs.gospeech.com/docs/validation-error",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "errors": {
  	"id": ["Id must be non-empty"]
  },
  "errorCodes": {
  	"id": [{
    	"code": "NotEmpty.Violated",
      "propertyValue": null
    }]
  }
}

Extensions

Problem details has the following 2 extensions to describe the errors.

errors - dictionary of errors, where the key is an invalid property name and the value is an array of human-readable error messages.

{
	"invalid_property_name": [
  	"Error message 1",
    "Error message 2"
  ],
  "invalid_property_name2": [
  	"Error message 3"
  ],
  ...
}

errorCodes - dictionary of errorCodes, where the key is an invalid property name and the value is an error code object with the following fields:

  • code - unique validation code which identifies the error.
  • propertyValue - the property value provided by a client.
  • each code can have extra fields with some additional information about the error.
{
	"invalid_property_name": [
    {
      "code": "validation_code",
      "propertyValue": "provided_value",
      "extra_field": "extra_field_value"
    },
    {
    	"code": "validation_code2",
      "propertyValue": "provided_value",
      "extra_field2": "extra_field_value2",
    }
  ],
  "invalid_property_name2": [
    {
      "code": "validation_code",
      "propertyValue": "provided_value",
      "extra_field": "extra_field_value"
    }
  ],
  ...
}

The table below describes all possible validation codes.

Validation codeDescriptionExtra fields
NotEmpty.ViolatedThe field is required, it cannot be null or an empty string
MaxLength.ViolatedThe provided string/array is out of the maximum allowed lengthmaxLength
MinLength.ViolatedThe provided string/array is out of the minimum allowed lengthminLength
Length.ViolatedThe rovided string/array must have an exact lengthminLength
maxLength
PositiveNumber.ViolatedThe number field has to be greater than or equal 0
MaxValue.ViolatedThe number field has to be less than an additionalmaxValue fieldmaxValue
AllowedCharacters.ViolatedThe provided string must consist of permitted characters.allowedCharacters
SupportedLanguage.ViolatedThe provided language is not supported
DictionariesCount.ViolatedThe provided dictionaries id count exceeds the maximum permitted number
ConsequentSpaces.ViolatedThe provided string contains more than one consecutive space character
VocabularyWordSpokenFormsCount.ViolatedThe provided spoken forms exceeds the maximum allowed permitted number
VocabularyWordSpokenFormMaxLength.ViolatedThe provided spoken form(s) exceed(s) the allowed length

Did this page help you?