Registry / testing / revalidator

revalidator

JSON →
library0.3.1jsnpmunverified

A cross-browser / Node.js validator with JSON Schema compatibility (draft-zyp-json-schema-04). Current stable version is 0.3.1, last released in 2015, no longer actively maintained. It provides a simple `validate(obj, schema)` function that returns `valid` boolean and `errors` array. Key differentiator is lightweight footprint and support for both Node.js and browser environments, but lacks modern JSON Schema features and complete format validation.

npm install revalidator
INSTALL
IMPORT
SIG · REVALIDATOR
R
revalidator
testingjavascriptv0.3.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

revalidator
import revalidator from 'revalidator'
import { revalidator } from 'revalidator'
Default export only; named import will be undefined.
revalidator
const revalidator = require('revalidator')
const { revalidator } = require('revalidator')
CommonJS style: direct require gets the default export.
validate
const { validate } = revalidator
import { validate } from 'revalidator'
validate is a method on the default export, not a named export. Must destructure after importing.

Shows basic usage of revalidator.validate() with a JSON Schema and an object, including optional error handling.

import revalidator from 'revalidator'; const schema = { properties: { name: { type: 'string', required: true, minLength: 2 }, age: { type: 'integer', minimum: 0 }, email: { type: 'string', pattern: '^[^@]+@[^@]+\.[^@]+$' } } }; const obj = { name: 'Alice', age: 30, email: 'alice@example.com' }; const result = revalidator.validate(obj, schema); console.log('Valid:', result.valid); if (!result.valid) { console.log('Errors:', result.errors); }
Debug
Known issues
deprecatedThe package is no longer maintained and may not work with newer Node.js versions.
fix
Consider migrating to a more modern validator like ajv or joi.
affects: >=0.3.1
gotchaThe validate method mutates the options object passed to it?
fix
Always pass a fresh options object if reusing the same schema with different options.
affects: >=0.3.0
gotchaThe 'additionalProperties' option defaults to true, meaning extra properties in the object are allowed unless explicitly set to false.
fix
Set additionalProperties: false in options to disallow unknown properties.
affects: >=0.3.0
gotchaThe 'type' property supports arrays (e.g., ['boolean', 'string']) but only validates against the first matching type?
fix
Use single type definitions for clarity.
affects: >=0.3.0
gotchaFormat validation is limited; for example, 'email', 'date', 'uri' are not validated unless registered via formatExtensions.
fix
Provide custom format validators or use a validator with built-in format support.
affects: >=0.3.0
Errors
Common errors & fixes
TypeError: revalidator.validate is not a function
Using named import instead of default import.
fix
Use: import revalidator from 'revalidator'; then revalidator.validate(...)
Cannot find module 'revalidator'
Package not installed.
fix
Run: npm install revalidator
Validation returns valid: true for extra properties when additionalProperties is false?
additionalProperties option only works at the root level, not nested schemas.
fix
Use a validator that supports recursive additionalProperties checks.
Upgrade
Version history
0.3.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
10
Resources
revalidator — npm install revalidator · libregistry