npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pajv

v1.2.0

Published

A command line JSON Schema validator that supports many file formats. Fork of jessedc/ajv-cli.

Downloads

84,076

Readme

Polyglottal JSON Schema Validator (Polyglottal Ajv)

Command line interface for ajv that utilizes any-json to provide validation against many data formats. pajv can validate: CSON, Hjson, JSON, JSON5, TOML, and YAML files using JSON Schema. pajv is a fork of ajv-cli.

Build Status npm version Code Climate Coverage Status

Contents

Installation

npm install -g pajv

Help

pajv help
pajv help validate
pajv help test

Validate data

This command validates data files against JSON-schema

pajv validate -s test/schema.json -d test/valid_data.json
pajv -s test/schema.json -d test/valid_data.json

You can omit validate command name.

Parameters

-s - file name of JSON-schema

Only one schema can be passed in this parameter

-d - JSON data

Multiple data files can be passed, as in -r parameter:

pajv -s test/schema.json -d "test/valid*.json"

If some file is invalid exit code will be 1.

-r - referenced schemas

The schema in -s parameter can reference any of these schemas with $ref keyword.

Multiple schemas can be passed both by using this parameter mupltiple times and with glob patterns. Glob pattern should be quoted and extensions cannot be omitted.

-m - meta-schemas

Schemas can use any of these schemas as a meta-schema (that is the schema used in $schema keyword - it is used to validate the schema itself).

Multiple meta-schemas can be passed, as in -r parameter.

-c - custom keywords/formats definitions

You can pass module(s) that define custom keywords/formats. The modules should export a function that accepts Ajv instance as a parameter. The file name should start with ".", it will be resolved relative to the current folder. The package name can also be passed - it will be used in require as is.

For example, you can use -c ajv-keywords to add all keywords from ajv-keywords package or -c ajv-keywords/keywords/typeof to add only typeof keyword.

Options

  • --errors=: error reporting format. Possible values:

    • js (default): JavaScript object
    • json: JSON with indentation and line-breaks
    • line: JSON without indentaion/line-breaks (for easy parsing)
    • text: human readable error messages with data paths
  • --changes=: detect changes in data after validation. Data can be modifyed with Ajv options --remove-additional, --use-defaults and --coerce-types). The changes are reported in JSON-patch format (RFC6902). Possible values are js (default), json and line (see --errors option).

Test validation result

This command asserts that the result of the validation is as expected.

pajv test -s test/schema.json -d test/valid_data.json --valid
pajv test -s test/schema.json -d test/invalid_data.json --invalid

If the option --valid (--invalid) is used for the test to pass (exit code 0) the data file(s) should be valid (invalid).

This command supports the same options and parameters as validate with the exception of --changes.

Ajv options

You can pass the following Ajv options:

|Option|Description| |---|---| |--data|use $data references| |--all-errors|collect all errors| |--unknown-formats=|handling of unknown formats| |--verbose|include schema and data in errors| |--json-pointers|report data paths in errors using JSON-pointers| |--unique-items=false|do not validate uniqueItems keyword| |--unicode=false|count unicode pairs as 2 characters| |--format=full|format mode| |--schema-id=|keyword(s) to use as schema ID| |--extend-refs=|validation of other keywords when $ref is present in the schema| |--missing-refs=|handle missing referenced schemas (true/ignore/fail)| |--inline-refs=|referenced schemas compilation mode (true/false/<number>)| |--remove-additional|remove additional properties (true/all/failing)| |--use-defaults|replace missing properties/items with the values from default keyword| |--coerce-types|change type of data to match type keyword| |--multiple-of-precision|precision of multipleOf, pass integer number| |--error-data-path=property|data path in errors| |--messages=false|do not include text messages in errors|

Options can be passed in either dash-case and camelCase.

See Ajv Options for more information.

Version History

See https://github.com/json-schema-everywhere/pajv/releases

Licence

MIT