sails-congruence
v0.0.2
Published
Generate browser-compatible validator functions for Sails.js models. A congruence extension.
Downloads
5
Maintainers
Readme
-congruence
Generate browser-compatible validator functions for Sails.js models. A congruence extension.
Install
$ npm install sails-congruence --save
Usage
Create a validator function from a model, e.g. Account:
var congruence = require('sails-congruence');
var validateAccount = congruence.getSailsValidator(Account);
var valid = validateAccount({
name: 'myaccount',
type: 'X'
})
// returns false. 'X' is not a valid account type
// https://github.com/tjwebb/xtuple-api/blob/master/api/models/Account.js#L17
API
.getSailsValidator(model)
Generate a Sails.js validator function for the specified model
| @param | description |
|:---|:---|
| model
| the model to create the validator function for |
| @return | description |
| Function
| a function that will return true if model is valid, false otherwise
License
MIT