simple object validation
simple-object-validation is a lightweight validation library that enables a functional way of validating javascript objects. It is made to work well with Redux Form's validation API.
Code over configuration
The idea is to use only functions and no constraint configuration or something like that. Typically in a more sophisticated web application user input validation can easily become very complex and specific. So there will be the need of writing custom validation code. You should always be able to easily plug your custom code into the standard library code without having to configure and register stuff intransparently somewhere else.
API Docs
Installation
npm install --save simple-object-validation
Examples
Simple registration form
const isValidCustomer = // { name: 'Name is required.', age: 'Age must be greater than or equal 18.' } // {}
I18n example
const nameTransformer = i18next const i18n_required = const i18n_greaterThanOrEqual = '' // 'Feld Postleitzahl ist ein Pflichtfeld.''Age''17' // 'Feld Alter muss größer oder gleich 18 sein.'
Integrate with Redux Form
/* ... contains redux form fields for customer, e. g. name, age and email */ form: 'customerRegistrationForm' validate: isValidCustomerCustomerRegistrationComponent
See detailed information on how to use Redux Form's validation API at http://redux-form.com > Examples
Coming soon
- immutable.js support
- More examples
Thanks
This library was heavily inspired by jfairbank/revalidate