nons

0.3.0 • Public • Published

nons

simple, lightweight schema validation library

Installation

npm i nons

Usage

const validate = require("nons");
const types = require("nons/types");

const scheme = {
  this: {
    can: {
      as: {
        nested: {
          as: types.string,
        },
        you: types.array,
      },
      like: types.number,
    },
    with: {
      "optional?": types.string,
    },
  },
};

validate(schema, {
  this: {
    can: {
      as: {
        nested: {
          as: "works!",
        },
        you: ["also", "works!"],
      },
      like: 1,
    },
    with: {}, // only child is optional, but parent is required
  },
});

Readme

Keywords

Package Sidebar

Install

npm i nons

Weekly Downloads

0

Version

0.3.0

License

MIT

Unpacked Size

93.6 kB

Total Files

8

Last publish

Collaborators

  • adityavm