
validate - DataPower Gateway (v5 compatible)
Use the validate policy to validate the payload in an assembly flow against a schema.
Gateway support
Note: This page describes the validate policy implementation
in the DataPower® Gateway
(v5 compatible). If you
are using the DataPower API
Gateway,
see validate - DataPower API Gateway.
For information on the different types of gateway, see API Connect gateway types.
Gateway | Policy version |
---|---|
DataPower Gateway (v5 compatible) | 1.0.0 |
This topic describes how to configure the policy in your OpenAPI source; for details on how to configure the policy in the assembly user interface, see Validate - DataPower Gateway (v5 compatible).
Restriction:
- The schema that represents the XML can reference only one XML namespace.
- The schema cannot reference polymorphic XML elements.
- The validation works on the
message.body
variable and not any other output/context variable. If the invoke policy contains a configured response object variable, thenmessage.body
is not set, and validate is not able to act. - If you use the
multipleOf
keyword in a schema definition for the API then, due to rounding behavior, the specified value must satisfy the following conditions, otherwise the validation fails when the API is called:- The value must not be less than
0.000000999999999999999848869
. - If the value is greater than 1, the amount before the decimal point must not be greater than
999999999999999934463
.
- The value must not be less than
About
The validate policy has
the following
format:
- validate:
version: version
title: title
description: description
definition: swagger_schema_definition_to_be_used
Apply this policy by adding an assembly extension with an execute field to your OpenAPI definition file.
Properties
The following table describes the policy properties:
Property | Required | Description | Data type |
---|---|---|---|
version | Yes | The policy version number | string |
title | No | A title for the policy. | string |
description | No | A policy description. | string |
definition | Yes | The schema to be used to validate the payload. Valid values:
|
string |
You can also apply an validate policy by using the API Designer assembly editor to add a built-in policy to the API. For more information, see Validate - DataPower Gateway (v5 compatible) in the built-in policies section.
Example 1
validate:
version: 1.0.0
title: validate the response
definition: #/definitions/RouteOutput