Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // adding custom operators
- $.policy.addOperator('defined', function(data, check) {
- return typeof data != 'undefined';
- });
- $.policy.addOperator('longer_than', function(data, check) {
- return data && data.hasOwnProperty('length') && data.length > check;
- });
- // add some policies
- $.policy.add('name.longer_than', 10);
- $('#our_people').find('.person').policy('in_set'); // our people with names longer than 10 characters
- $('#our_people').find('.person').policy('not_in_set'); // our people with names shorter than 10 characters
- // we can also namespace policies
- $.policy.add('price.gteq', 25000, 'price_between_25_50k');
- $.policy.add('price.lteq', 50000, 'price_between_25_50k');
- $('li.products').policy('in_set', 'price_between_25_50k'); // all products with data-price between
- // 25,000 and 50,000 (inclusive)
- $('li.products').policy('not_in_set', 'price_between_25_50k'); // all the rest of the products
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement