Gathering detailed insights and metrics for @jirutka/ajv-cli
Gathering detailed insights and metrics for @jirutka/ajv-cli
Gathering detailed insights and metrics for @jirutka/ajv-cli
Gathering detailed insights and metrics for @jirutka/ajv-cli
npm install @jirutka/ajv-cli
Typescript
Module System
Node Version
NPM Version
TypeScript (88.21%)
JavaScript (11.79%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
6 Stars
335 Commits
1 Forks
1 Branches
1 Contributors
Updated on Jun 04, 2025
Latest Version
6.0.0
Package Id
@jirutka/ajv-cli@6.0.0
Unpacked Size
197.69 kB
Size
44.44 kB
File Count
73
NPM Version
10.9.2
Node Version
22.13.1
Published on
Feb 20, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
9
25
Command line interface for Ajv, a JSON Schema validator.
This is a fork of the original ajv-cli 5 with many improvements (see below).
Notable changes from the original ajv-cli 5.
A new human-friendly error format pretty
that combines the source file location and JSON path of the invalid value, followed by a code span (a snippet of the validated file) with an in-place error message (see Pretty format in Examples).
A new error format line
: <filepath>:<line>:<column> - <message>
(see Line format in Examples).
Support for the Code Climate Issue format compatible with the Code Quality report in GitLab CI (see Code Climate format in Examples).
A validate option --merge-errors
, enabled by default, to merge related errors per instance path instead of reporting individual schema errors as returned by Ajv (see JSON format without merging errors in Examples).
A validate option --errors-location
to add the source location (filename, line and column number) of each invalid value to validation errors (see JSON format with location in Examples).
A compile option --code-esm
to export the validate function(s) as ECMAScript Modules (ESM) instead of CommonJS (see code.esm
in Ajv options).
Workaround to fix incorrect schemaPath
in validation errors (see src/ajv-schema-path-workaround.ts and ajv-validator/ajv#512).
-d
option has been replaced with positional arguments (ajv validate -s <schema> <data-file>…
).
--no-<option>
no longer works, boolean options can be disabled as --<option>=false
or --<option> false
.
The validate
command is no longer implicit, it must always be specified (e.g. ajv validate [options]
, not ajv [options]
).
Limited glob support – The bloated Glob dependency has been replaced by picomatch and a custom implementation to traverse directories. However, it’s a simplified solution that does not support complex nested globs (e.g. alpha/beta/*.{yml,d/**/*.yml}
).
The default error format has been changed from js
to pretty
.
The line
format has been renamed to json-oneline
.
The text
format for errors has been replaced by the jsonpath
format.
Only (structured) validation errors (see --errors
) and changes (see --changes
) are printed to stdout, all other messages are logged to stderr.
--strict-schema
is disabled by default* (i.e. unknown keywords and formats are ignored) to comply with the JSON Schema specification.
ajv compile
prints the generated code to stdout instead of nowhere if the -o
option is not specified.
The default value of --inline-refs
has been changed from true
to 8
to speed up schema compilation (and validation).
If --spec
is not provided, it’s determined by the $schema
URI in the first passed schema (-s
). It will only fallback to draft-07
if it’s not found.
ajv-cli is now transpiled to ECMAScript Modules (ESM) instead of CommonJS.
The test command (use validate
instead).
The migrate command.
Support for loading schema and data files via require
and omitting the .json
extension in file paths.
Support for loading custom keywords modules in TypeScript.
Loading schemas and data in the JSON5 format (CJSON is still supported).
1npm install --global @jirutka/ajv-cli
ajv-cli is also provided as a single JavaScript file with bundled dependencies, requiring only Node.js (version 20 or later) on the system.
1curl -LO https://github.com/jirutka/ajv-cli/releases/download/v6.0.0/ajv.cjs 2curl -fsSL https://github.com/jirutka/ajv-cli/releases/download/v6.0.0/checksums.txt | sha256sum -c --ignore-missing 3install -D -m755 ajv.cjs /usr/local/bin/ajv
Refer to ajv validate --help
and ajv compile --help
.
$ ajv validate -s schema.json data-invalid-1.yml
--> data-invalid-1.yml:6:10
#/www.encom.com/CNAME
| A: 1.2.3.4
| www.encom.com:
| owners: flynnsam
6 | CNAME: [ encom.com ]
| ^^^^^^^^^^^^^ must be string or object
| tron.encom.com:
| owners: [ flynnkev, bradlala ]
| A: 1.2.3.5
$ ajv validate -s schema.json --errors=line data-invalid-1.yml
data-invalid-1.yml:6:10 - must be string or object
$ ajv validate -s schema.json --errors=json data-invalid-1.yml
1[ 2 { 3 "message": "must be string or object", 4 "instancePath": "/www.encom.com/CNAME", 5 "schemaPath": "#/$defs/DomainObject/properties/CNAME/anyOf" 6 } 7]
$ ajv validate -s schema.json --errors=json --errors-location data-invalid-1.yml
1[ 2 { 3 "message": "must be string or object", 4 "instancePath": "/www.encom.com/CNAME", 5 "schemaPath": "#/$defs/DomainObject/properties/CNAME/anyOf", 6 "instanceLocation": { 7 "filename": "data-invalid-1.yml", 8 "start": { 9 "line": 6, 10 "col": 10 11 }, 12 "end": { 13 "line": 6, 14 "col": 23 15 } 16 } 17 } 18]
$ ajv validate -s schema.json --errors=json --verbose data-invalid-1.yml
1[ 2 { 3 "message": "must be string or object", 4 "instancePath": "/www.encom.com/CNAME", 5 "schemaPath": "#/$defs/DomainObject/properties/CNAME/anyOf", 6 "data": [ 7 "encom.com" 8 ], 9 "schema": [ 10 { 11 "$ref": "#/$defs/DomainName" 12 }, 13 { 14 "type": "object", 15 "additionalProperties": false, 16 "required": [ 17 "rdata" 18 ], 19 "properties": { 20 "rdata": { 21 "$ref": "#/$defs/DomainName" 22 }, 23 "ttl": { 24 "type": "number" 25 } 26 } 27 } 28 ], 29 "parentSchema": { 30 "anyOf": [ 31 { 32 "$ref": "#/$defs/DomainName" 33 }, 34 { 35 "type": "object", 36 "additionalProperties": false, 37 "required": [ 38 "rdata" 39 ], 40 "properties": { 41 "rdata": { 42 "$ref": "#/$defs/DomainName" 43 }, 44 "ttl": { 45 "type": "number" 46 } 47 } 48 } 49 ] 50 } 51 } 52]
$ ajv validate -s schema.json --errors=json --merge-errors=false data-invalid-1.yml
1[ 2 { 3 "instancePath": "/www.encom.com/CNAME", 4 "schemaPath": "#/$defs/DomainName/type", 5 "keyword": "type", 6 "params": { 7 "type": "string" 8 }, 9 "message": "must be string" 10 }, 11 { 12 "instancePath": "/www.encom.com/CNAME", 13 "schemaPath": "#/$defs/DomainObject/properties/CNAME/anyOf/1/type", 14 "keyword": "type", 15 "params": { 16 "type": "object" 17 }, 18 "message": "must be object" 19 }, 20 { 21 "instancePath": "/www.encom.com/CNAME", 22 "schemaPath": "#/$defs/DomainObject/properties/CNAME/anyOf", 23 "keyword": "anyOf", 24 "params": {}, 25 "message": "must match a schema in anyOf" 26 } 27]
$ ajv validate -s schema.json --errors=code-climate data-invalid-1.yml
1[ 2 { 3 "description": "[schema] #/www.encom.com/CNAME must be string or object", 4 "check_name": "json-schema", 5 "fingerprint": "344ef8205ab8c5dea3b0ebd537519dfb005c5f5c", 6 "severity": "major", 7 "location": { 8 "path": "data-invalid-1.yml", 9 "positions": { 10 "begin": { 11 "line": 6, 12 "column": 10 13 }, 14 "end": { 15 "line": 6, 16 "column": 23 17 } 18 } 19 } 20 } 21]
This project is a fork of the original ajv-cli written by Evgeny Poberezkin.
The code for merging related Ajv validation errors is taken from the vscode-lintlens project by Gabriel McAdams.
This project is licensed under MIT License.
No vulnerabilities found.
No security vulnerabilities found.