Class: HTTPRequestValidationHandler

vertx-web-api-contract-js/http_request_validation_handler~ HTTPRequestValidationHandler

new HTTPRequestValidationHandler()

An interface for add HTTP Request validation. This class can validate parameters inside query, path, headers an body (watch below)
You can assign multiple body type at the same time(for example a JSON schema together with a XML schema). This interface support:
  • application/x-www-form-urlencoded
  • multipart/form-data
  • application/xml
  • application/json
Also you can add a form parameter for validation without care about content type of your request. For form parameters this interface support both "multipart/form-data" and "application/x-www-form-urlencoded"
This interface allow extra parameters in the request, so it doesn't care if in a request there's a parameter without a specified validation rule
If a parameter is flagged as an array, it will be validated also if the size of array is 1 element
Source:

Methods

addCustomValidatorFunction(customValidator) → {HTTPRequestValidationHandler}

Add a custom validator. For more informations about custom validator, see CustomValidator
Parameters:
Name Type Description
customValidator CustomValidator
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addExpectedContentType(contentType) → {HTTPRequestValidationHandler}

Add an expected content type of request. It's not needed to add application/json, application/xml, multipart/form-data and application/x-www-form-urlencoded
Parameters:
Name Type Description
contentType string expected content type of file
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addFormParam(parameterName, type, required) → {HTTPRequestValidationHandler}

Add a single parameter inside a form with included parameter types
Parameters:
Name Type Description
parameterName string expected name of parameter inside the form
type Object expected type of parameter
required boolean true if parameter is required
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addFormParamsArray(parameterName, type, required) → {HTTPRequestValidationHandler}

Add a form parameters array with included parameter types
Parameters:
Name Type Description
parameterName string expected name of array of parameters inside the form
type Object expected type of array of parameters
required boolean true if parameter is required
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addFormParamsArrayWithPattern(parameterName, pattern, required) → {HTTPRequestValidationHandler}

Add a form parameters array with a custom pattern
Parameters:
Name Type Description
parameterName string expected name of array of parameters inside the form
pattern string regular expression for validation
required boolean true if parameter is required
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addFormParamWithCustomTypeValidator(parameterName, validator, required, allowEmptyValue) → {HTTPRequestValidationHandler}

Add a form parameter with a custom type validator. For more informations about how to construct built-in or custom type validator, check out ParameterTypeValidator
Parameters:
Name Type Description
parameterName string expected name of parameter inside the form
validator ParameterTypeValidator type validator
required boolean true if parameter is required
allowEmptyValue boolean true if parameter allowEmptyValue. For more informations about allowEmptyValue behaviour: ParameterValidationRule#allowEmptyValue
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addFormParamWithPattern(parameterName, pattern, required) → {HTTPRequestValidationHandler}

Add a single parameter inside a form with a custom pattern
Parameters:
Name Type Description
parameterName string expected name of parameter inside the form
pattern string regular expression for validation
required boolean true if parameter is required
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addHeaderParam(headerName, type, required) → {HTTPRequestValidationHandler}

Add a header parameter with included parameter types
Parameters:
Name Type Description
headerName string expected header name
type Object expected type of parameter
required boolean true if parameter is required
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addHeaderParamWithCustomTypeValidator(headerName, validator, required, allowEmptyValue) → {HTTPRequestValidationHandler}

Add a header parameter with a custom type validator. For more informations about how to construct built-in or custom type validator, check out ParameterTypeValidator
Parameters:
Name Type Description
headerName string expected header namery
validator ParameterTypeValidator type validator
required boolean true if parameter is required
allowEmptyValue boolean true if parameter allowEmptyValue. For more informations about allowEmptyValue behaviour: ParameterValidationRule#allowEmptyValue
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addHeaderParamWithPattern(headerName, pattern, required) → {HTTPRequestValidationHandler}

Add a header parameter with a custom pattern
Parameters:
Name Type Description
headerName string expected header name
pattern string regular expression for validation
required boolean true if parameter is required
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addJsonBodySchema(jsonSchema) → {HTTPRequestValidationHandler}

Add a json schema for body with Content-Type "application/json"
Parameters:
Name Type Description
jsonSchema string
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addMultipartRequiredFile(filename, contentType) → {HTTPRequestValidationHandler}

Add an expected filename inside multipart request.
Parameters:
Name Type Description
filename string name of the file inside the form
contentType string expected content type of file
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addPathParam(parameterName, type) → {HTTPRequestValidationHandler}

Add a path parameter with included parameter types. All path params are required
Parameters:
Name Type Description
parameterName string expected name of parameter inside the path
type Object expected type of parameter
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addPathParamWithCustomTypeValidator(parameterName, validator, allowEmptyValue) → {HTTPRequestValidationHandler}

Add a path parameter with a custom type validator. All path params are required. For more informations about how to construct built-in or custom type validator, check out ParameterTypeValidator
Parameters:
Name Type Description
parameterName string expected name of parameter inside the path
validator ParameterTypeValidator type validator
allowEmptyValue boolean true if parameter allowEmptyValue. For more informations about allowEmptyValue behaviour: ParameterValidationRule#allowEmptyValue
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addPathParamWithPattern(parameterName, pattern) → {HTTPRequestValidationHandler}

Add a path parameter with a custom pattern. All path params are required
Parameters:
Name Type Description
parameterName string expected name of parameter inside the path
pattern string regular expression for validation
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addQueryParam(parameterName, type, required) → {HTTPRequestValidationHandler}

Add a query parameter with included parameter types
Parameters:
Name Type Description
parameterName string expected name of parameter inside the query
type Object expected type of parameter
required boolean true if parameter is required
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addQueryParamsArray(arrayName, type, required) → {HTTPRequestValidationHandler}

Add a query parameters array with included parameter types
Parameters:
Name Type Description
arrayName string expected name of array inside the query
type Object expected type of parameter
required boolean true if parameter is required
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addQueryParamsArrayWithPattern(arrayName, pattern, required) → {HTTPRequestValidationHandler}

Add a query parameters array with a custom pattern
Parameters:
Name Type Description
arrayName string expected name of array inside the query
pattern string regular expression for validation
required boolean true if parameter is required
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addQueryParamWithCustomTypeValidator(parameterName, validator, required, allowEmptyValue) → {HTTPRequestValidationHandler}

Add a query parameter with a custom type validator. For more informations about how to construct built-in or custom type validator, check out ParameterTypeValidator
Parameters:
Name Type Description
parameterName string expected name of parameter inside the query
validator ParameterTypeValidator type validator
required boolean true if parameter is required
allowEmptyValue boolean true if parameter allowEmptyValue. For more informations about allowEmptyValue behaviour: ParameterValidationRule#allowEmptyValue
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addQueryParamWithPattern(parameterName, pattern, required) → {HTTPRequestValidationHandler}

Add a query parameter with a custom pattern
Parameters:
Name Type Description
parameterName string expected name of parameter inside the query
pattern string regular expression for validation
required boolean true if parameter is required
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

addXMLBodySchema(xmlSchema) → {HTTPRequestValidationHandler}

Add a xml schema for body with Content-Type "application/xml"
Parameters:
Name Type Description
xmlSchema string
Source:
Returns:
this handler
Type
HTTPRequestValidationHandler

handle(arg0)

Parameters:
Name Type Description
arg0 RoutingContext
Source: