You can use the request-validation
policy to validate an incoming HTTP request according to defined rules.
A rule is defined for an input value. This input value supports Expression Language expressions and is validated against constraint
rules.
Constraint rules can be:
-
NOT_NULL
— Input value is required -
MIN
— Input value is a number and its value is greater than or equal to a given parameter -
MAX
— Input value is a number and its value is lower than or equal to a given parameter -
MAIL
— Input value is valid according to the mail pattern -
DATE
— Input value is valid according to the date format pattern given as a parameter -
PATTERN
— Input value is valid according to the pattern given as a parameter -
SIZE
— Input value length is between two given parameters -
ENUM
— Field value included in ENUM
By default, if none of the rules can be validated, the policy returns a 400
status code.
Property | Required | Description | Type | Default |
---|---|---|---|---|
scope |
X |
Phase when the policy is executed |
Policy scope |
ON_REQUEST |
status |
X |
HTTP status code send to the consumer in case of validation issues |
HTTP status code |
400 |
rules |
X |
Rules to apply to incoming request |
List of rules |
- |
You can use the response template feature to override the default response provided by the policy. These templates must be defined at the API level (see the API Console Response Templates option in the API Proxy menu).