Registry / devops / pajv
library1.2.0jsnpmunverified

pajv is a command-line JSON Schema validator that supports multiple data formats including CSON, Hjson, JSON5, TOML, and YAML, in addition to standard JSON. Version 1.2.0 is the latest stable release, built on top of Ajv (Another JSON Schema Validator) and any-json for format parsing. It provides a unified CLI interface for validating data files against JSON Schema, with features like referenced schemas, custom keywords, and error formatting. pajv is a fork of ajv-cli and extends its functionality to support polyglottal input formats. The project is actively maintained with regular updates.

npm install pajv
INSTALL
IMPORT
SIG · PAJV
P
pajv
devopsjavascriptv1.2.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.

pajv CLI
Use the command line directly: pajv validate -s schema.json -d data.json
const pajv = require('pajv'); // pajv is not a JavaScript library, it's a CLI tool
pajv is a CLI tool, not a library. Do not attempt to import it programmatically; use child_process.spawn or shell commands instead.
Ajv (programmatic use)
import Ajv from 'ajv'
import pajv from 'pajv' // pajv does not export an Ajv instance
If you need programmatic validation, use the 'ajv' package directly. pajv is only for CLI usage.
Validate via CLI
pajv validate -s schema.json -d data.yaml
pajv -s schema.json -d data.yaml --errors json // valid but --errors option uses equals sign
The global install is `npm install -g pajv`. Validate command can be omitted: `pajv -s schema.json -d data.json`.

Installs pajv globally and validates a YAML file against a JSON Schema, showing success vs failure.

npm install -g pajv # Create a JSON schema file: schema.json cat > schema.json << EOF { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "number" } }, "required": ["name"] } EOF # Create a valid YAML data file: valid_data.yaml echo "name: John Doe age: 30" > valid_data.yaml # Valid YAML against schema pajv validate -s schema.json -d valid_data.yaml # Exit code 0, no output # Invalid data: missing required field 'name' echo "age: 25" > invalid_data.yaml pajv validate -s schema.json -d invalid_data.yaml # Exit code 1, prints error
Debug
Known issues
gotchapajv is a CLI tool, not a JavaScript library. Do not attempt to import it programmatically with require or import.
fix
Use child_process.spawn or exec to run pajv commands, or use the 'ajv' package directly for programmatic validation.
affects: >=1.0.0
gotchaSchema file must be JSON or YAML; data files can be in CSON, Hjson, JSON, JSON5, TOML, or YAML. Using unsupported formats will throw an error.
fix
Ensure data files have recognized extensions (.json, .yaml, .yml, .toml, .cson, .hjson, .json5) or use any-json directly.
affects: >=1.0.0
gotchaGlob patterns for -d and -r must be quoted in the shell to prevent expansion.
fix
Use quotes: pajv -s schema.json -d "test/*.json"
affects: >=1.0.0
deprecatedAs of Ajv v7, the default AJV schema draft is draft-07. Old schemas using draft-04 or draft-06 need explicit specification via --spec option.
fix
Add --spec draft-04 or --spec draft-06 if needed. Note: pajv uses Ajv's default settings.
affects: >=1.0.0
gotchaCustom keywords via -c must export a function that accepts an Ajv instance. The file must have a leading dot-slash or be a package name.
fix
Example: pajv -s schema.json -d data.json -c ./my-keywords.js or -c ajv-keywords
affects: >=1.0.0
Errors
Common errors & fixes
pajv: command not found
pajv is not installed or not in PATH.
fix
Run `npm install -g pajv` and ensure npm global bin directory is in your PATH.
Error: Cannot find module 'ajv'
Missing Ajv dependency when using custom keywords or if pajv installation is broken.
fix
Run `npm install -g pajv` again to ensure dependencies are installed.
data_path: should be string
Schema expects a string but data provides a number or other type.
fix
Ensure data matches schema type constraints. Example schema: { "type": "string" }
ENOENT: no such file or directory
Specified schema or data file does not exist.
fix
Check file paths and use absolute or correct relative paths. Use -s ./schema.json if needed.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
ajvrequiredCore validation engine; pajv uses Ajv for schema validation.
any-jsonrequiredParses multiple data formats (CSON, Hjson, JSON5, TOML, YAML) into JSON.
Agent activity
12 hits · last 30 days
node
10
Amazon
1
Resources
packagepajv
pajv — npm install pajv · libregistry