Interface RequestValidator
public interface RequestValidator
The
RequestValidator requires the parameters in a specific format to be able to
parse and validate them. This is especially true for exploded parameters. The following table shows how the
value of a parameter of a request must be stored in a ValidatableRequest object. For these examples the key
of those values is always color.
These are the initial values for each type:- primitive (string) -> "blue"
- array -> ["blue","black","brown"]
- object -> { "R": 100, "G": 200, "B": 150 }
ValidatedRequest.getCookies()
+--------+---------+-------+-----------+------------------------------------+-------------------------+ | style | explode | empty | primitive | array | object | +--------+---------+-------+-----------+------------------------------------+-------------------------+ | form | false | | blue | blue,black,brown | R,100,G,200,B,150 | +--------+---------+-------+-----------+------------------------------------+-------------------------+ | form | true | | blue | color=blueinvalid input: '&color'=blackinvalid input: '&color'=brown | R=100invalid input: '&G'=200invalid input: '&B'=150 | +--------+---------+-------+-----------+------------------------------------+-------------------------+For header parameters
ValidatedRequest.getHeaders()
+--------+---------+-------+-----------+------------------------------------+-------------------------+ | style | explode | empty | primitive | array | object | +--------+---------+-------+-----------+------------------------------------+-------------------------+ | simple | false | | blue | blue,black,brown | R,100,G,200,B,150 | +--------+---------+-------+-----------+------------------------------------+-------------------------+ | simple | true | | blue | blue,black,brown | R=100,G=200,B=150 | +--------+---------+-------+-----------+------------------------------------+-------------------------+For path parameters
ValidatedRequest.getPathParameters()
+--------+---------+--------+-------------+-------------------------------------+--------------------------+ | style | explode | empty | primitive | array | object | +--------+---------+--------+-------------+-------------------------------------+--------------------------+ | simple | false | | blue | blue,black,brown | R,100,G,200,B,150 | +--------+---------+--------+-------------+-------------------------------------+--------------------------+ | simple | true | | blue | blue,black,brown | R=100,G=200,B=150 | +--------+---------+--------+------ ------+-------------------------------------+--------------------------+ | label | false | . | .blue | .blue,black,brown | .R,100,G,200,B,150 | +--------+---------+--------+-------------+-------------------------------------+--------------------------+ | label | true | . | .blue | .blue.black.brown | .R=100.G=200.B=150 | +--------+---------+--------+-------------+-------------------------------------+--------------------------+ | matrix | false | ;color | ;color=blue | ;color=blue,black,brown | ;color=R,100,G,200,B,150 | +--------+---------+-------+--------+-------------------------------------------+--------------------------+ | matrix | true | ;color | ;color=blue | ;color=blue;color=black;color=brown | ;R=100;G=200;B=150 | +--------+---------+--------+-------------+-------------------------------------+--------------------------+For query parameters
ValidatedRequest.getQuery()
+----------------+---------+-------+------------+-----------------------------------+--------------------------+ | style | explode | empty | primitive | array | object | +----------------+---------+-------+----------+-------------------------------------+--------------------------+ | form | false | | blue | blue,black,brown | R,100,G,200,B,150 | +----------------+---------+-------+-----------+------------------------------------+--------------------------+ | form | true | | blue | color=blueinvalid input: '&color'=blackinvalid input: '&color'=brown | R=100invalid input: '&G'=200invalid input: '&B'=150 | +----------------+---------+-------+------ ----+------------------------------------+--------------------------+ | spaceDelimited | false | not yet supported / +----------------+---------+-------+------ ----+------------------------------------+--------------------------+ | spaceDelimited | true | not yet supported / +----------------+---------+-------+------ ----+------------------------------------+--------------------------+ | pipeDelimited | false | not yet supported / +----------------+---------+-------+------ ----+------------------------------------+--------------------------+ | pipeDelimited | true | not yet supported / +----------------+---------+-------+------ ----+------------------------------------+--------------------------+ | spaceDelimited | true | not yet supported / +----------------+---------+-------+------ ----+------------------------------------+--------------------------+
-
Method Summary
Modifier and TypeMethodDescriptionstatic RequestValidatorcreate(Vertx vertx, OpenAPIContract contract) Create a newRequestValidator.validate(HttpServerRequest request) Likevalidate(ValidatableRequest, String), but the operationId andValidatableRequestare determined from the passed request.validate(HttpServerRequest request, String operationId) Likevalidate(ValidatableRequest, String), butValidatableRequestare directly extracted from the passed request.validate(ValidatableRequest params, String operationId) Validates the passed request parameters against the operation defined in the related OpenAPI contract.
-
Method Details
-
create
Create a newRequestValidator.- Parameters:
vertx- the related Vert.x instancecontract- the relatedOpenAPIContract- Returns:
- an instance of
RequestValidator.
-
validate
Likevalidate(ValidatableRequest, String), but the operationId andValidatableRequestare determined from the passed request. Note: Determining the operationId is expensive. If possible usevalidate(HttpServerRequest, String).- Parameters:
request- the request to validate- Returns:
- A succeeded Future with the parsed and validated request parameters, or a failed Future containing ValidationException.
-
validate
Likevalidate(ValidatableRequest, String), butValidatableRequestare directly extracted from the passed request.- Parameters:
request- the request to validateoperationId- the id of the related operation.- Returns:
- A succeeded Future with the parsed and validated request parameters, or a failed Future containing ValidationException.
-
validate
Validates the passed request parameters against the operation defined in the related OpenAPI contract.- Parameters:
params- the request parameters to validate.operationId- the id of the related operation.- Returns:
- A succeeded Future with the parsed and validated request parameters, or a failed Future containing ValidationException.
-