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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@az-tech/schemas

v0.9.2

Published

Schema builder and validator

Readme

##Schemas schema.js provides a simple schema constructor which provides validation methods of models.

###Usage Create a schema file for your model, ie: 'myModel.schema.js', and require the 'schema.js' file in it. Create an object representing the model and call new Schema(myModel) to create the new model schema.

###Schema API myschema.validate(object) = Will validate the data being passed in against the model schema definition. This method will run the following commands.

mySchema.validateFieldType(field, modelField) = Validates that the property is of the proper data type. field is a string representing the property name of the schema. modelField is the property on the data to be validated.

mySchema.validateDateString(val) = Validates that date strings are proper ISO format.

myschema.validateLength(field, modelField) = Validates that the length of the field is neither over the maxLength or under the minLength of that property. fieldis the name of the prop to validate, modelField is the property value to be validated.

###Model Definitions Define model schemas as an object of key: value pairs where key is the name of the property and value is an object with the property defitions. Current property values are as follows:

type: the data type of the property. Currently supported types are 'string','number','boolean','arrary', and 'date'. 'date' is current;ly assumed to be an ISO String.
required: A boolean value to specify whether a property is required to pass validation. Not providing a required key:pair will default to required:false
minLength: A number value to designate the minimum length of the property. Not providing a minLength will default the value to 0;
maxLength: A number value to designate the maximum length of the property. Not providing a minLength will default the value to null, allowing unlimited length;
default: Default value for property. If the data provided has a key: value pair it will use those values, otherwise it will use the provided default or null if no default is provided.

###Example: A model like:

const myModel = new Schema({
    properties:{
        name: {required: true, type: 'string'},
        age: {required: false, type: 'number', minLength: 2, maxLength: 3},
        createdAt: {required: true, type: 'date'},
        updatedAt: {required: true, type: 'date'},
        active: {required: true, type: 'boolean'}
    }
})

will create a new schema with 5 properties.

Calling validate on an object will validate the object against the schema, returning either true, or an array of strings, with the strings detailing the issues with the validation.