express-validation v4.1.1 is an Express middleware that validates request parameters (body, query, headers, params, cookies, signedCookies) using Joi schemas. It returns structured error responses when validation fails and integrates with Express error handlers. The library has a hard dependency on Joi v17.x.x and ships with TypeScript definitions. It is actively maintained with regular releases, and provides multiple error format options including keyByField. Compared to alternatives like express-validator, it uses Joi directly rather than its own validator.
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
ESM import; CommonJS destructure works too.
import { validate } from 'express-validation'
Named export for error class.
import { ValidationError } from 'express-validation'
Re-exported Joi from express-validation for convenience.
import { Joi } from 'express-validation'
Sets up an Express app with POST /login route that validates email and password using Joi schemas via express-validation middleware and handles errors with a custom error handler.
import express from 'express';
import { validate, ValidationError, Joi } from 'express-validation';
const loginValidation = {
body: Joi.object({
email: Joi.string().email().required(),
password: Joi.string().regex(/[a-zA-Z0-9]{3,30}/).required(),
}),
};
const app = express();
app.use(express.json());
app.post('/login', validate(loginValidation, {}, {}), (req, res) => {
res.json(200);
});
app.use((err, req, res, next) => {
if (err instanceof ValidationError) {
return res.status(err.statusCode).json(err);
}
return res.status(500).json(err);
});
app.listen(3000);
Upgrade
Version history
Breaking-change detection hasn't run for this library yet.
Audit
Security & dependencies
CVE tracking and dependency tree are planned for a later release.