simple-hoc-validator
Simple rule-based validation HOC
This is a very simple HOC, for someone who wants to do simple validations on React components. If you need advanced stuff, this is not it :) This was not made with performance in mind either, so...
Install
Install with npm:
$ npm install --save simple-hoc-validator
Usage
;; const rules = field: 'name' value !== null && value !== undefined && value !== '' error: 'Name is empty' field: 'password' value === objcompare_password error: "Passwords don't match" ; Component { if thisprops ; } { const errors = thisprops; if errorsname ; if errorspassword ; } rulesMyFormComponent;
Tests
Nah. Just works.
Licence
See LICENCE.
Contributing
As I use this for my own projects, I know this might not be the perfect approach for all the projects out there. If you have any ideas, just open an issue and tell me what you think.
If you'd like to contribute, please fork the repository and make changes as you'd like. Pull requests are warmly welcome.
MIT © Heber Nobre