DataPower
Gateway

Validate - DataPower Gateway (v5 compatible)

Use the Validate policy to validate the payload in an assembly flow against a JSON or an XML schema.

Gateway support

Note: This topic 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.

Table 1. Table showing which gateways support this policy, and the corresponding policy version
Gateway Policy version
DataPower Gateway (v5 compatible) 1.0.0

This topic describes how to configure the policy in the assembly user interface; for details on how to configure the policy in your OpenAPI source, 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, then message.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.

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 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 2. 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 definition to be used to validate the payload that is returned from other invoke actions or tasks in the assembly flow. For information on defining a schema for an API definition, see Editing an API definition.
string