Validate (validate)
Use the Validate policy to validate the payload in an assembly flow against a JSON or an XML schema.
Restriction:
- The schema that represents the XML can reference only one XML namespace.
- The schema cannot reference polymorphic XML elements.
- The OpenAPI
discriminator
field is not supported by the Validate policy. - The Validate policy can be used only with the DataPower® Gateway, not with the Micro Gateway.
- Validate 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.
About
You can attach this policy to the following API flow:
- REST
Position this policy where required in the assembly flow as follows:
- To validate the original input, position a Validate policy at the start of your flow.
- To validate an intermediate response that is returned from other invoke actions or tasks, position a Validate policy after those actions or tasks.
- To validate the response that is returned to the client application, position a Validate policy after the task that collates the response.
You can apply a different OpenAPI (Swagger 2.0) schema definition to each Validate policy either by choosing from the set of schema definitions that is specified at the API level, or the schema definition at the operation level.
Properties
The following table lists the policy properties, indicates whether a property is required, specifies the valid and default values for input, and specifies the data type of the values.
Property label | Required | Description | Data type |
---|---|---|---|
Title | Yes | The title of the policy. The default value is |
string |
Description | No | A description of the policy. | string |
Definition | Yes | Specifies the schema definition to be used for validating the payload. Valid values:
|
string |