Skip to main content
Version: 57.2.0

createValidator

createValidator(options): (req, res, next) => void

Creates a combined validation middleware for both body and query parameters.

Parameters

options

CreateValidatorOptions

Configuration for what to validate

Returns

Express middleware function

(req, res, next) => void

Example

router.post("/search", [
openApiMiddleware,
createValidator({
body: {query: {type: "string", required: true}},
query: {limit: {type: "number"}},
}),
], handler);