0.0.2 • Published 10 years ago

sails-congruence v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

-congruence

Generate browser-compatible validator functions for Sails.js models. A congruence extension.

NPM version Build status Dependency Status

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

@paramdescription
modelthe model to create the validator function for
@returndescription
Functiona function that will return true if model is valid, false otherwise

License

MIT