Skip to main content
This schema validation template is designed to manage and enforce validation rules for incoming requests at Run API (Endpoints). It ensures that requests conform to predefined standards by validating query parameters, headers, and the request body based on specified rules. Below, you will find a detailed explanation of the template, its properties, and examples of how to configure it for different scenarios.

Supported guards

Initial template properties such as query and headers are static and it’s schema type must be type of object. For property body this is only the example to show how to accept all payloads.

Template format

We recommend using our WebUI to create Schema Validator Components but, if you want to use your own JSON editor, we recommend setting up schema below as validator for your file.

Properties

Definition - ValidatorProperty

Definition - ValidatorObject

Snippets

Examples

We provide a few examples on how to configure validator and samples.
  • Query
  • Headers
  • Body (payload)
It will work the same if you put it in either query or body, you can mix these inside single Guard and validate Query Headers and Body in the same time..

Example 1: Validate required property.

Here we only validate single header input, also we set as required so call’s without providing a header will fail.

Example 2: Validate a different format of payload.

Array of Objects

Assuming our endpoint consumes array of products, it validates that payload is valid JSON but it is not JSON Object {} but array [] and it has at least two elements, where each must have two properties productId and price, where price must be in range of 0-100.
Configuration

Object

Assuming our endpoint consumes single object of product, similar to the example above, however now it validates that payload is valid JSON Object {} and not array [] it has two properties productId and price, where price must be in range of 0-100.
Configuration

Example 3: Validate advanced query parameter.

Custom Error Response

Besides shown examples and default response, you can configure its behavior, which is described below.

Custom Bad Request

Customize Guard failed validation response.