bookshelf-validation
A simple & flexible model validation plugin for bookshelf
How to use
You can install it from npm package.
$ npm install bookshelf-validation
And then plug it into bookshelf instance.
const knex = client: 'sqlite3' connection: filename: ':memory:' ;const Bookshelf = knex; Bookshelf;
Now you are ready to use bookshelf-validation
.
const validator = ; let User = BookshelfModel;
bookshelf-validation
simply provides two model validation properties required
and validator
.
The default value of required
field is false
unless you explicitly specify it.
validator
is just a function returns true
/ false
, so it's highly customizable. I prefer to use it with validator library which has lots of built-in functions.