thug-validations

An add-on module for Thug models. Thug is a functional approach to orm filters and validations.

thug-validations

Thug is a functional model system for nodejs, this module is an add-on module of common validations that any model may use.

https://github.com/sintaxi/thug

Thug was created to minimize the complexity of validating and altering an object before writing it to a data store or performing an operation. Thug is not an ORM but is ment to be a replacment for one. Thug is very small and works on both the server or in a browser.

npm install thug-validations --save

Thug Model

var Thug = require('thug');
var validations = require('thug-validations');
 
module.exports = function(config) {
  var post = new Thug({
    "validations": {
      "title"         : [validations.present],
      "author"      : [validations.present, validations.email]
    }
  });
  return post;
}

field should be present when validated.

field should use validator to confirm field formats as an email address.

doc should contain an additional confirmation field and validate equality.

MIT

pull requests are welcome!

More validations coming, these are just to get the ball rolling.