JSON Validator rule

Use the JSON Validator rule to validate a request against a JSON schema. Limit JSON structures to minimize content-level attacks.

Validates a request against a JSON schema. You can specify limits on various JSON structures, such as arrays and strings. This capability minimizes the risk posed by content-level attacks. The rule applies only to requests with the Content-Type set to application/json.

Policy execution order

This JSON Validator rule executes after the request is authenticated.

Rule fields include:

Field Description
When this rule should be applied An expression that defines one or more conditions that must be true for the rule to execute.

Example: The expression request.method == "POST" causes the rule to execute only on POST requests.

Edit Json Schema The schema to use for valication. Launches the JSON editor. You can create import an existing JSON file from the SnapLogic file system or create a new one. The editor loads an existing JSON document if defined previously.

Default value: Empty JSON file

Example:

{
    "$schema": "http://json-schema.org/draft-06/schema#",
    "type": "object",
    "properties": {
        "foo": {
            "type": "integer"
        },
        "bar": {
            "type": "string"
        }
    }
}
Hide/Render WhiteSpace Formats JSON with watermarked dots or plain white space between the characters.
Format Code Formats text in JSON
Description

A customizable description.

Default value: Requests are being validated against the specified schema

Troubleshooting rule violations

The JSON Validator rule now returns the actual rule violation error to the API caller. Each error type is parameterized and added to the response in the "SL_Policy_Error" header.

The following image provides an example of a rule violation error.

Policy Violation Error Image

First, a required field (productId) is missing a value. Secondly, the value for the price field is invalid.