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.| Type | Description | 
|---|---|
| query | Validation on query parameters level (must be object). | 
| headers | Validation on headers level (must be object). | 
| body | Perform payload validation. | 
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
| Property | Type | Description | 
|---|---|---|
| whitelist | Boolean | Determines whether properties not explicitly defined in the schema are allowed. If set to true, extra properties are permitted; if set tofalse, they are not. | 
| whitelistErrors | Boolean | Controls whether errors are thrown for properties not included in the whitelist. The default is false, which means errors are not thrown unless this is set totrue. | 
| schema | Object(ValidatorProperty) | Defines the validation rules for various components of the request such as queryparameters,headers, and thebody. | 
Definition - ValidatorProperty
| Property | Type | Description | 
|---|---|---|
| type | String | Specifies the data type of the property (e.g., string,number,boolean,object,array,date,any).any- accepts everything, useful when you would like to whitelist optional properties and remove others | 
| required | Boolean | Indicates whether the property must be present in the request. | 
| regex | String | A regular expression that the property value must match, if applicable. | 
| min | Number | Sets the minimum value or length for the property. Applicable to numeric values and lengths of strings or arrays. | 
| max | Number | Sets the maximum value or length for the property. Applicable to numeric values and lengths of strings or arrays. | 
| objectSchema | Array(ValidatorObjectitems) | Defines a schema for properties when the type is object. Includes an array ofValidatorObjectitems. | 
| arraySchema | Object(ValidatorProperty) | Describes the schema for array items when the type is array. | 
Definition - ValidatorObject
| Property | Type | Description | 
|---|---|---|
| property | String | The name of the property in the request. | 
| schema | Object(ValidatorProperty) | The detailed schema definition for the property based on ValidatorProperty. | 
Snippets
Default JSON Template
Default JSON Template
JSON Validator (Schema)
JSON Validator (Schema)
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
Error - Bad Format
Error - Bad Format
Error - Min elements in array validation
Error - Min elements in array validation
Error - Wrong format of elements
Error - Wrong format of elements
Error - Maximum allowed value in element property
Error - Maximum allowed value in element property
Error - Wrong format of value in element property
Error - Wrong format of value in element property
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
Error - Bad Format
Error - Bad Format
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.
