urb

1.0.1 • Public • Published

urb

npm Version npm Downloads

Table of contents

About

Dead simple object schema validation for Node.js.

Installation

Use the package manager npm to install urb:

npm install urb

Usage

const urb = require("urb");

const schema = {
    "required": {
        "one": "string",
        "two": "boolean",
        "three": {
            "four": "boolean"
        }
    },
    "optional": {
        "five": "string"
    }
}

const res = urb.validate(schema, {
    "one": "hello",
    "two": "world",
    "three": {
        "four": true
    }
});

console.log(res.valid); // false

The res object returned consists of the following:

{
    "valid": false,
    "errors": [
        "two must be undefined"
    ]
}

Types

  • array
  • boolean
  • bson object id
  • defined
  • undefined
  • email
  • function
  • nested schema (see usage)
  • number
  • object
  • string
  • uuid

Is something missing or misbehaving? Open an issue.

Links

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Package Sidebar

Install

npm i urb

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

11.8 kB

Total Files

19

Last publish

Collaborators

  • moaufmklo