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 code

Description

Extra fields

NotEmpty.Violated

The field is required, it cannot be null or an empty string

MaxLength.Violated

The provided string/array is out of the maximum allowed length

maxLength

MinLength.Violated

The provided string/array is out of the minimum allowed length

minLength

Length.Violated

The rovided string/array must have an exact length

minLength
maxLength

PositiveNumber.Violated

The number field has to be greater than or equal 0

MaxValue.Violated

The number field has to be less than an additionalmaxValue field

maxValue

AllowedCharacters.Violated

The provided string must consist of permitted characters.

allowedCharacters

SupportedLanguage.Violated

The provided language is not supported

DictionariesCount.Violated

The provided dictionaries id count exceeds the maximum permitted number

ConsequentSpaces.Violated

The provided string contains more than one consecutive space character

VocabularyWordSpokenFormsCount.Violated

The provided spoken forms exceeds the maximum allowed permitted number

VocabularyWordSpokenFormMaxLength.Violated

The provided spoken form(s) exceed(s) the allowed length