Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arnaudrinquin/checkmate
Checkmate is a very simple data validator
https://github.com/arnaudrinquin/checkmate
Last synced: 21 days ago
JSON representation
Checkmate is a very simple data validator
- Host: GitHub
- URL: https://github.com/arnaudrinquin/checkmate
- Owner: ArnaudRinquin
- Created: 2017-01-05T08:58:08.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-17T12:11:37.000Z (almost 8 years ago)
- Last Synced: 2024-10-25T14:27:41.976Z (2 months ago)
- Language: JavaScript
- Homepage: https://arnaud.rocks/checkmate/
- Size: 73.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# checkmate
[![Build Status](https://travis-ci.org/ArnaudRinquin/checkmate.svg?branch=master)](https://travis-ci.org/ArnaudRinquin/checkmate) [![npm version](https://badge.fury.io/js/checkmate.svg)](https://badge.fury.io/js/checkmate)
Checkmate is a very simple data validator.
*Use cases*
* form input validation
* model validation*Characteristics*
* no dependency
* framework / lib / context agnostic: describe what you expect → send an object → get errors
* does not come with validation functions, write your own or combine with libraries such as [`is.js`](http://is.js.org/)*Example*
See the [`react + is_js`](./examples/react-is_js) example.
```js
import checkmate from 'checkmate'
import is from 'is_js'const checkers = checkmate({
email: {
notEmpty: (str) => !is.empty(str),
isEmail: is.email,
},
password: {
truthy: (str) => !!str,
minLength: (str) => str && str.length > 7,
},
})const errors = checkers({
email: 'arnaud@efounderscom',
password: false,
})console.log(errors)
// → { email: ['isEmail'], password: ['truthy'] }
```