DataPower Gateway only

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, then message.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.

Table 1. Validate policy properties
Property label Required Description Data type
Title Yes The title of the policy.

The default value is validate.

string
Description No A description of the policy. string
Definition Yes Specifies the schema definition to be used for validating the payload.
Valid values:
  • request: Select this value to validate the request input against the schema definition that is specified in the Type field for the request parameter for this operation. For information about how to create a request parameter, see Configuring an operation.
  • response: Select this value to validate the response to be returned to the client application, against the schema definition that is specified in the Schema field for the response parameter for this operation. For information about how to create a response parameter, see Configuring an operation.
  • #/definitions/definition_name: Select this value for a previously defined schema to be used to validate the payload that is returned from other invoke actions or tasks in the assembly flow.
string