sails-congruence

0.0.2 • Public • Published

-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

@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

Package Sidebar

Install

npm i sails-congruence

Weekly Downloads

0

Version

0.0.2

License

MIT

Last publish

Collaborators

  • tjwebb