403 - Invalid format
A validation error is an error due to invalid client requests.
All validation errors correspond with a 403 HTTP status code.
A validation error occurs when:
- Request body is ill-formed
e.g. invalid JSON - Required parameters are missing (either in body or in query string)
e.g. endpoint required a field which is (empty or) not specified in the request - Endpoint validation rules are not matched
e.g. minimum/maximum length constraint doesn't match
VALIDATION ERROR OBJECT
Property | Type | Description |
---|---|---|
property | string | Request property which originated the error |
message | string | Message to the user explaining what happened |
verbose | string | Message to the developer futher explaining what happened |
code | string enum - InvalidFormat - RequiredField - InvalidLength - InvalidMinLength - InvalidMaxLength - InvalidEmailAddress - OutOfRange - PatternMismatch - PrefixMismatch - InvalidCharacter - MustBeLowerCase - MustBeUpperCase | Machine readable code to handle the error |
Example validation error: missing required field
// HTTP status 403
{
"code": "RequiredField",
"message": "Cannot be empty",
"property": "slashtag"
}
Example of validation error: invalid min length
// HTTP status 403
{
"property": "slashtag",
"message": "Value cannot be less than 2 characters long",
"code": "InvalidMinLength",
"input": "a",
"minLength": 2
}
Example of validation error: OutOfRange
// HTTP status 403
{
"property": "regType",
"message": "Value is not allowed",
"code": "OutOfRange",
"input": "cat",
"range": ["individual", "business"]
}
Following additional properties may appear in validation errors:
Property | Type | Description |
---|---|---|
input | object | Original input value for property |
minLength | numerical Positive | Minimum length allowed |
maxLength | numerical Strictly positive | Maximum length allowed |
length | numerical Strictly positive | Length to match |
range | array of objects | Set of allowed values |
pattern | string regex | Regex to test the input with |
prefix | string | Prefix that input has to match |
character | string | Character given in input |
Validation error codes
Code | Additional properties | Message | Description |
---|---|---|---|
InvalidFormat | none | Invalid format | Generic invalid format error with respect to the property value |
RequiredField | none | Cannot be empty | Field indicated in property was empty or not specified in the request |
InvalidLength | input, length | Value cannot be different than length characters long | Number of characters of property value not matching length |
InvalidMinLength | input, minLength | Value cannot be less than minLength characters long | Value for field indicated in property was too short with respect to minLength |
InvalidMaxLength | input, maxLength | Value cannot be more than maxLength characters long | Value for field indicated in property was too long with respect to maxLength |
InvalidEmailAddress | input | Value is not a valid email address | Value for field indicated in property was not a valid email address |
OutOfRange | input, range | Value is not allowed | Value for field indicated in property was not included in range |
PatternMismatch | input, pattern | Invalid format | Value for field indicated in property does not match regex in pattern |
PrefixMismatch | input, prefix | Prefix mismatch | Prefix of value for field indicated in property does not match prefix |
InvalidCharacter | input, character | Invalid character: 'character ' | Value for field indicated in property contains invalid character |
MustBeLowerCase | input | Value must be lowercase | Value for field indicated in property is not lowercased |
MustBeUpperCase | input | Value must be uppercase | Value for field indicated in property is not uppercased |
Updated 7 months ago