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

jsontest

v0.0.7

Published

Testing JSON data structures using CSS3-like selectors

Downloads

24

Readme

jsontest

Test your JSON output with JSON tests using JSON rules resulting in JSON output, which can then be tested with more JSON.

Yo dawg...

Getting Started

If you haven't used grunt before, be sure to check out the Getting Started guide, as it explains how to create a gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, install this plugin with this command:

$ npm install jsontest --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('jsontest');

Tip: the load-grunt-tasks module makes it easier to load multiple grunt tasks.

Validators

jsontest provides several powerful means of writing a particular assertion. There may be some overlap in what's available to validate a value against. Use whichever means makes most sense for your application.

iz Rules

A target can assert with a JSON object assigned to the rules property. This allows one to write assertion validation rules using the iz library's JSON interface. Some validators it supports are listed here:

Method | Function ------------------------------: | :--------------------------------------------------------------------------- alphaNumeric(); | Is number or string(contains only numbers or strings) between(number, start, end); | Number is start or greater but less than or equal to end, all params numeric blank(); | Empty string boolean(); | true, false, 0, 1 cc(); | Luhn checksum approved value date(); | Is a date obj or is a string that is easily converted to a date decimal(); | int or float email(); | Seems like a valid email address empty(); | If an object, array or function contains no properties true. All primitives return true. equal(, ); | Any 2 things are strictly equal. If 2 objects their internal properties will be checked. If the first parameter has an equals method that will be run instead extension(ob1, ob2); | If obj2's methods are all found in obj1 fileExtension(value, arr); | Checks if the extension of value is in arr. An obj can be provide, but must have indexOf defined. fileExtensionAudio(value); | Check against mp3, ogg, wav, aac fileExtensionImage(value); | Check against png, jpg, jpeg, gif, bmp, svg, gif inArray(value, arr); | If * is in the array int(, bool (optional)); | Is an int. If the 2nd variable is true (false by default) a decimal is allowed ip(str); | str resembles an IPV4 or IPV6 address minLength(val, min); | val (str or arr) is greater than min maxLength(val, max); | val (str or arr) is shorter than max multiple(num, mult); | Number is multiple of another number number(); | Is either an int or decimal ofType(obj, typeName); | If it is a named object, and the name matches the string phone(str, canHaveExtension?); | Is an american phone number. Any punctuations are allowed. postal(); | Is a postal code or zip code required(); | Is not null, undefined or an empty string ssn(); | Is a social security number string(); | Is the argument of type string

Math.js Expressions

It's also possible to use an inequality or other mathematical expression that is evaluated using a string in the Math.js expression format. As long as the value is included as part of the expression, it can be used with numbers declared within that expression.

For example:

"length": "val > 0"