Formations
A simple and complete server-side and client-side validations library in ES6 JavaScript compiled with Babel.
Influence
Play Framework 2.x.x allows easily defined and testable form validations.
Features
- Easily transformable constraints i.e.
number.min(10).max(56)
ortext.matches("[A-Za-z]")
- Makes no assumption of client/server
- Validates JSON forms
"true"
andtrue
will both validate as booleans (same with other validation types)- Validate on your own "types" by writing
text
constraints - Cross-form validation (lame example for now)
Install
To install, just run: npm install --save formations
Usage
Here is an example validation for a register form.
;; var form = formations; var registerValidation = name: textmaxLength32 "Your name must be less than 33 characters.." password: text email: emailmaxLength64 "Use a smaller e-mail, please!" age: number correctAge: boolean; var results = formations; ifresults console;else console;
List of validations
- number
- text
- boolean
If there is a validation "type" we don't have, just write a text
validation and write the needed constraints.
Contributing
Open pull requests and issues whenever needed!