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

yajsv

v0.7.5

Published

yet another json schema validator

Downloads

68

Readme

yajsv

Greenkeeper badge build status Current Version dependency Status devDependency Status Coveralls

Unstable changing api, wrapper interface to z-schema

Example usage

const Manager = require('yajsv');  // Load module
const schemas = require('/path/to/schemas'); // Load schemas either in an array or object sets
const manager = new Manager({
    formats: {} // optional object to register custom formats
});  // create constructor
manager.addSchemas(schemas);  // create schemas for validation
manager.addFormats(formats); // add a formats object to be registering with z-schema
const results = manager.compile(); // build schemas based on inputted schemas

API

new Manager(options);

creates the yajsv constructor object, valid options are

  • formats - optional param is an object with keys being the name of formats to register and value is function with either one paramater for sync and two for async with a (value, callback) signature
manager.addSchemas(schemas);

method to create schemas for validation, the schemas must be an array of valid schema objects or an object with keys being each type (collections, definitions, records) each with keys being the name of object and the value the respective schema

manager.addFormats(formats);

method to add custom formats to z-schema, the formats argument is an object with keys the name of the format and the value is the function to register. See lib/register for formats that are already registered

manager.toJson(match);

method to return either an object with the keys being the names of all schemas with values being json strings called by passing '*' to method or by passing a name of schema to return as json the schema name must be passed to method to return the strignified schema

manager.compile();

method to verify all schema that have been created are valid, returns an object with two keys

  • schemas - an object with each key being the name of created schema
  • formats - an object with each key being the name of format and the value being the required function to be registered with z-schema

cli

installation

npm i -g yajsv

usage

yajsv -i path/to/input -o path/to/output -f path/to/formats/file -s testSchema
Input -i

Directory containing folder names collections, records and definitions. They must containing relevant schema files in the respective directories

Output -o

Output directory where json-schemas will be saved to

Formats -f

Formats option is path to a valid formats file

Schema -s

Schema is either a name of the schema you want to save to file or default is a * which means all schemas in directory will be saved

Version -v

Prints version of yajsv

Help -h

Prints usage of cli

Todo

  • Abstracted away from a specific validation library
  • Document the required schema objects to parse and build json-schema complaint schemas
  • Improve documentation especially of yajsv cli interface
  • Remove custom formats interface?