Registry /
web-framework / node-restify-validation
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.
validationPlugin
✓ const restifyValidation = require('node-restify-validation');
// then use restifyValidation.validationPlugin
✗ import { validationPlugin } from 'node-restify-validation';
This library is written for CommonJS (`require`) environments. Direct ESM `import` statements may not work without transpilation or specific Node.js configuration.
validation route property
✓ server.get({ url: '/test', validation: { ... } }, handler)
Validation rules are defined directly as a `validation` property within the route object passed to Restify methods like `server.get`, `server.post`, etc.
Initializes a Restify server with the validation plugin and defines a GET route with path, query, and header parameter validation rules, demonstrating how to attach validation schemas directly to routes.
const restify = require('restify');
const restifyValidation = require('node-restify-validation');
const server = restify.createServer();
server.use(restify.queryParser());
server.use(restify.bodyParser()); // Required for 'content' validation
server.use(restifyValidation.validationPlugin({
errorsAsArray: false,
forbidUndefinedVariables: false,
errorHandler: restify.errors.InvalidArgumentError
}));
server.get({
url: '/test/:name',
validation: {
resources: { // Path parameters
name: { isRequired: true, isIn: ['foo', 'bar'] }
},
queries: { // Query parameters
status: { isRequired: true, isIn: ['foo', 'bar'] },
email: { isRequired: false, isEmail: true },
age: { isRequired: true, isNatural: true }
},
headers: { // HTTP Headers
requestid: { isRequired: true }
}
}
}, function (req, res, next) {
res.send(200, { message: `Hello ${req.params.name}, your status is ${req.query.status}.` });
return next();
});
server.listen(8001, function () {
console.log('%s listening at %s', server.name, server.url);
});
Debug
Known issues
breakingThe project is explicitly marked as 'Maintener wanted' in its README. This indicates that the library is unmaintained, will not receive bug fixes, security patches, or new features. Using it in production carries significant risk.fixConsider migrating to an actively maintained validation library for Restify (if one exists) or forking the project and taking on maintenance responsibilities if continued use is critical. Restify itself has seen limited recent activity.
affects: >=1.0.0
gotchaThis library has a strict dependency on `restify >= 2.6.0`. Using older versions of `restify` will lead to runtime errors due to changes in Restify's route object API that `node-restify-validation` relies upon.fixEnsure that your project's `package.json` specifies a `restify` dependency of version `2.6.0` or higher.
affects: <1.0.0 (of node-restify-validation used with restify < 2.6.0)
gotchaThe library is primarily designed for CommonJS (`require()`) environments. While Node.js offers some interoperability, using ES Module `import` syntax directly might cause issues without proper configuration or transpilation.fixAlways use `const restifyValidation = require('node-restify-validation');` for importing the module in your Node.js applications. affects: All versions
gotchaBy default, validation failures trigger a `restify.errors.InvalidArgumentError`. Applications must implement appropriate error handling middleware in Restify to gracefully catch and respond to these validation errors, rather than letting them crash the server or return generic 500s.fixImplement a global error handler for your Restify server using `server.on('restifyError', function (req, res, err, next) { /* handle error */ });` to catch `InvalidArgumentError` and send appropriate HTTP responses (e.g., 400 Bad Request). affects: All versions
Errors
Common errors & fixes
TypeError: server.use is not a function
The `restify` server instance has not been properly created before attempting to attach middleware.
fixEnsure `const server = restify.createServer();` is called before any `server.use()` statements.
Error: InvalidArgumentError: Resource 'name' is required but was not found.
A request parameter (path, query, body, or header) marked as `isRequired: true` in the validation schema was missing from the incoming request.
fixVerify that the client request includes all required fields as defined in the route's `validation` object. Check the exact field name and location (resources, queries, content, headers).
ReferenceError: restify is not defined
The `restify` module was not imported or required at the top of the file.
fixAdd `const restify = require('restify');` to your file before using the `restify` variable. TypeError: Cannot read properties of undefined (reading 'validationPlugin')
The `node-restify-validation` module was not correctly imported or `require`d, leading to `restifyValidation` being `undefined`.
fixEnsure `const restifyValidation = require('node-restify-validation');` is correctly placed and executed. Audit
Dependencies
restifyrequiredCore dependency for building REST services that this library validates. Requires restify >= 2.6.0.