Registry / testing / json-schema-util

json-schema-util

JSON →
library1.0.1jsnpmunverified

A lightweight JSON schema validator utility for Node.js, version 1.0.1. Provides a simple validate() function that returns isValid and errors. Minimal dependencies, synchronous API. Suitable for basic schema validation, but lacks advanced features like format validation or remote schema support found in libraries like Ajv. Use with caution for complex schemas.

npm install json-schema-util
INSTALL
IMPORT
SIG · JSON-SCHEMA-UTIL
J
json-schema-util
testingjavascriptv1.0.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.

validate
import { validate } from 'json-schema-util'
const validate = require('json-schema-util')
Correct ESM import; default import does not work. CJS require() returns an object with validate.
default import
import * as util from 'json-schema-util' util.validate(data, schema)
import validate from 'json-schema-util'
No default export; use namespace or named import.
validate
const { validate } = require('json-schema-util')
const validate = require('json-schema-util').validate;
Destructuring is preferred but the dot-access also works.

Validates a simple object against a JSON schema and logs validity and errors.

const schema = { type: "object", properties: { name: { type: "string" } } }; const data = { name: "Alice" }; const { validate } = require('json-schema-util'); const result = validate(data, schema); console.log(result.isValid); // true console.log(result.errors); // null if valid
Debug
Known issues
gotchaThe package uses a simple validator that may not support draft-07+ features like if/then/else or const.
fix
Consider Ajv for full JSON Schema draft support.
affects: >=1.0.0
gotchaErrors object structure may vary; property name in error is misspelled as 'tessNum' in example.
fix
Always check error object keys in your code; do not rely on undocumented structure.
affects: >=1.0.0
deprecatedPackage has low maintenance and may not receive updates for newer Node.js versions.
fix
Migrate to actively maintained validator like Ajv.
affects: >=1.0.0
gotchaNo format validation (e.g., email, date-time) out of the box.
fix
Implement custom format validators or switch to Ajv with format plugin.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: validate is not a function
Using default import instead of named import.
fix
Use named import: const { validate } = require('json-schema-util');
Cannot find module 'json-schema-util'
Package not installed or wrong npm package name.
fix
Run npm install json-schema-util
Property 'errors' is null but expected array
Result.errors is null when validation succeeds, not an empty array.
fix
Check result.errors !== null before iterating.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
3 hits · last 30 days
node
2
Amazon
1
Resources
json-schema-util — npm install json-schema-util · libregistry