Registry / testing / another-json-schema

another-json-schema

JSON →
library4.0.0jsnpmunverified

A simple, flexible, and intuitive JSON Schema validator for Node.js. Version 4.0.0 supports nested schemas, type checking, required fields, defaults, enums, pattern matching, and custom validators like isEmail and trim. It mutates the input object by applying defaults and trims. Compared to ajv, it is less compliant with JSON Schema spec but offers a simpler API and easier custom extensions. Release cadence is low; the package appears in maintenance mode with infrequent updates.

npm install another-json-schema
INSTALL
IMPORT
SIG · ANOTHER-JSON-SCHEM
A
another-json-schema
testingjavascriptv4.0.0
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.

default
const AJS = require('another-json-schema')
import AJS from 'another-json-schema'
Package is CommonJS only; no ESM export. Using ES import will fail.
AJS
const AJS = require('another-json-schema')
const { AJS } = require('another-json-schema')
Default export, not named.
validate result
const result = schema.validate(data) if (!result.valid) { throw result.error }
const valid = schema.validate(data)
validate() returns an object with valid, error, and result; not a boolean.

Shows how to define a schema, validate data, and see the result object with applied defaults.

const AJS = require('another-json-schema'); const userSchema = AJS('userSchema', { name: { type: 'string', required: true }, age: { type: 'number', gte: 18 }, gender: { type: 'string', enum: ['male', 'female'], default: 'male' }, email: { type: 'string', trim: true, isEmail: true } }); const data = { name: 'Alice', age: 25 }; const result = userSchema.validate(data); console.log(result.valid); // true console.log(result.result); // { name: 'Alice', age: 25, gender: 'male' }
Debug
Known issues
gotchavalidate() mutates the input object by applying defaults and trim transformations.
fix
Pass a clone if you need to preserve original: schema.validate(JSON.parse(JSON.stringify(data)))
affects: >=0.1.0
gotchaNested schemas may fail silently if sub-schema is not defined via AJS(). Use AJS() for each nested object.
fix
Always define sub-schemas with AJS('name', {...}) to get proper validation.
affects: >=0.1.0
deprecatedThe package has not been updated since 2018 and may not support newer Node.js versions or modern JavaScript features.
fix
Consider migrating to ajv or another actively maintained JSON Schema validator.
affects: <=4.0.0
Errors
Common errors & fixes
Cannot find module 'another-json-schema'
Package not installed or installation failed.
fix
Run 'npm install another-json-schema' in your project directory.
TypeError: AJS is not a constructor
Using ES import syntax with a CommonJS-only package.
fix
Use 'const AJS = require('another-json-schema')' instead of import.
TypeError: schema.validate is not a function
Calling validate on something that is not a schema object (e.g., forgot to call AJS).
fix
Ensure you create a schema: const schema = AJS('name', { ... })
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
36 hits · last 30 days
node
26
OpenAI (training)
1
Resources
another-json-schema — npm install another-json-schema · libregistry