urb
v1.0.1
Published
Dead simple object schema validation for Node.js
Downloads
2
Maintainers
Readme
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
- 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.