Skip to main content
Feedback

JSON Validation Policy

The JSON Validation policy allows JSON payload validation. This policy uses JSON Schema Validator It returns 400 BAD REQUEST when request validation fails and 500 INTERNAL ERROR when response validation fails, with a custom error message body.

Timing

On RequestOn ResponseOn Request ContentOn Response Content
XX

Configuration

PropertyRequiredDescriptionTypeDefault
scopeyesPolicy scope from where the policy is executed. REQUEST_CONTENT and RESPONSE_CONTENTpolicy scopeREQUEST_CONTENT
errorMessageyesCustom error message in JSON format. Spel is allowed.string{"error":"Bad request"}
schemayesJSON schema.string
deepChecknoValidates descendant even if the JSON parent container is invalid.booleanfalse
validateUncheckednoUnchecked validation means that conditions which would normally cause the processing to stop with an exception are instead inserted into the resulting report. ::: Caution: Anomalous events such as unresolvable JSON Reference, or an invalid schema, will be masked. :::booleanfalse
straightRespondModenoOnly for RESPONSE scope. If set to true, responses that failed to validate will be sent to the user without replacement.booleanfalse

HTTP Status Code

CodeMessage
400 (request scope) and 500 (response scope)In case of:
  • Invalid payload
  • Invalid JSON schema
  • Invalid error message JSON format

Example

{
"scope": "REQUEST_CONTENT",
"errorMessage": "Any custom error message",
"schema": "{\"$schema\": \"https://json-schema.org/draft-04/schema#\\", \"type\": \"object\", \"properties\": { \"value1\": {\"type\": \"string\" }, \"value2\": { \"type\": \"string\"}}, \"required\": [\"value1\", \"value2\"]}",
"deepCheck": false,
"validateUnchecked": false,
"straightRespondMode": false
}
On this Page