Registry / http-networking / express-jsonschema

express-jsonschema

JSON →
library1.1.6jsnpmunverified

Express middleware for JSON Schema validation, currently at version 1.1.6. It leverages the jsonschema library to validate request bodies against JSON Schema v4. The library provides a simple validate() middleware that attaches validation results to req.validations. Error handling is left to the developer, allowing custom responses. Compared to express-validator or Joi, this library decouples validation logic from schema definitions. It is in maintenance mode, with the last release in 2016 and no recent updates.

npm install express-jsonschema
INSTALL
IMPORT
SIG · EXPRESS-JSONSCHEMA
E
express-jsonschema
http-networkingjavascriptv1.1.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

validate
const validate = require('express-jsonschema').validate;
const validate = require('express-jsonschema');
The default export is an object; validate is a named export. CommonJS only.
JsonSchemaValidation
const JsonSchemaValidation = require('express-jsonschema').JsonSchemaValidation;
const { JsonSchemaValidation } = require('express-jsonschema');
JsonSchemaValidation is a class used for error handling; it is not a default export.
validate (ESM)
import { validate } from 'express-jsonschema';
import validate from 'express-jsonschema';
ESM imports are supported but not documented; use named import.

Demonstrates setting up an Express endpoint with JSON Schema validation for the request body and a custom error handler.

const express = require('express'); const { validate } = require('express-jsonschema'); const app = express(); app.use(require('body-parser').json()); const schema = { type: 'object', properties: { name: { type: 'string' }, age: { type: 'number' } }, required: ['name'] }; app.post('/user', validate({ body: schema }), (req, res) => { res.json({ valid: true }); }); app.use((err, req, res, next) => { if (err.name === 'JsonSchemaValidation') { res.status(400).json({ errors: err.validations }); } else { next(err); } }); app.listen(3000);
Debug
Known issues
gotchaThe validate() function expects an object with keys 'body', 'query', or 'params' - not just a schema object.
fix
Use validate({ body: schema }) instead of validate(schema).
affects: >=0.0.0
gotchaError handling must be explicitly implemented; unhandled validation errors will crash the app.
fix
Add Express error middleware checking for err.name === 'JsonSchemaValidation'.
affects: >=0.0.0
deprecatedThe project has not been updated since 2016 and does not support modern Express versions (4.17+).
fix
Consider migrating to @express-validator/express-validator or joi-based middleware.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: validate is not a function
Attempted to use default import without destructuring.
fix
Use const { validate } = require('express-jsonschema');
Cannot read property 'body' of undefined
The validate() call is missing the request property key, e.g., validate({ body: schema }).
fix
Pass an object with key 'body', 'query', or 'params'.
Upgrade
Version history
1.1.6latest on npm
Audit
Dependencies
jsonschemarequiredCore validation library; express-jsonschema wraps jsonschema to provide Express middleware.
Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
express-jsonschema — npm install express-jsonschema · libregistry