Q:

Use waterline criteria to verify an object?

While I use sails I wish to be able to check (before actually inserting the data into a database) if an object would fullfil a waterline criteria, and thus be later returned by a query?
A waterline criteria would look like:
{
  myvalue: 500,
  othervalue: { in: ['hello', 'world'] }
}

And many more statements (documentation). 
This would be tested against an object like:
{
  myvalue: 500,
  othervalue: 'hello',
  moredata: 'foo'
}

Which would return fit the criteria, while:
{
  myvalue: 600,
  othervalue: 'hello',
}
{
  myvalue: 500,
  othervalue: 'bar',
}
{
  myvalue: 500,
}

Would all fail the criteria. - Can I test a waterline criteria against such an in memory object (Or array of objects)? Other than obviously writing my own interpreter for the ruleset.

A:

Try to use Waterline-Criteria library
https://github.com/balderdashy/waterline-criteria#filtering-an-array.
var WLCriteria = require('waterline-criteria');
var results = WLCriteria(dataset, criteria);

