Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maximilianschmitt/valee
A validator for (nested) objects with a simple API.
https://github.com/maximilianschmitt/valee
Last synced: about 1 month ago
JSON representation
A validator for (nested) objects with a simple API.
- Host: GitHub
- URL: https://github.com/maximilianschmitt/valee
- Owner: maximilianschmitt
- License: mit
- Created: 2014-12-11T13:30:30.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-04-24T15:26:03.000Z (over 9 years ago)
- Last Synced: 2024-11-18T19:09:32.751Z (about 2 months ago)
- Language: JavaScript
- Size: 156 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# valee
[![Travis Build](http://img.shields.io/travis/maximilianschmitt/valee.svg?style=flat)](https://travis-ci.org/maximilianschmitt/valee) [![Coverage Status](https://coveralls.io/repos/maximilianschmitt/valee/badge.svg)](https://coveralls.io/r/maximilianschmitt/valee)
> A validator for (nested) objects with a simple API. For sanitizing objects, check out [sanee](https://github.com/maximilianschmitt/sanee).
## Usage
### Installation
```
$ npm install valee
```### Example
``` js
var valee = require('valee');// define schema
var validate = valee({
acceptAgreement: valee.isIn(['0', '1']),
request: {
ip: valee.isIP()
},
user: {
firstName: valee.isLength(1).isUppercase(),
email: valee.isEmail()
}
});// validate data
var errors = validate({
acceptAgreement: '1',
request: {
ip: '192.168.0.1'
},
user: {
firstName: 's',
email: '[email protected]'
}
});// print errors
console.log(errors);
```Output:
```
{
user: {
firstName: true
}
}
```## Validators
All validators of valee currently map to the [validators of validator.js](https://github.com/chriso/validator.js#validators).
## Todo:
* [x] Validation chaining
* [x] Nested objects
* [x] Sanitizers ([sanee](https://github.com/maximilianschmitt/sanee))
* [ ] Custom validators
* [ ] Automatic error messages
* [ ] Custom error messages
* [ ] required/notRequired