balderdashy/waterline — pull request #144 by ragulka (2013-10-17 16:03:42+00:00)
Title: Abstract validate() method

There are cases when it is desirable to only validate a model without saving/creating/updating it. It comes in handy when dealing with nested models and complex validations, for example.

I suggest abstracting the validation from different queries into a separate class or instance method that would allow doing something like this:

```javascript
var email = new Email({ recipient: "not_an_email" });
email.validate( function(err) {
if (err) return cb(err);
cb();
});
```

This should of course trigger the `beforeValidation` and `afterValidation` callbacks as well.

It probably also has the benefit of keeping things more DRY - currently the code for calling before/after validation lifecycle callbacks and validation is defined in 3 different files: dql.js, composite.js and aggregate.js - and by the looks of it, it's the same everywhere.

I could even try and submit a PR, but I am new to Sails/Waterline so I am not sure I understand the architecture well enough to do so yet.