utils/obj.utils.js
function matchesCriteria(data, criteria) {
        data = data || {};
        criteria = criteria || {};

        var match = true;
        _.each(criteria, function (val, key) {
            var hasNotOperand = false;

            if (_.isObject(val) && val['$ne'] ) {
                hasNotOperand = true;
                val = val['$ne'];
            }
            var dataValue = getNestedValue(data, key);
            if (_.isString(val) && _.isArray(dataValue)) { // allows you to check if an array contains a value
                match = (dataValue.indexOf(val) > -1);
            }
            else {
                var vals = _.isArray(val) ? val : [val];
                if (vals.indexOf(dataValue) < 0) {
                    match = false;
                }
                if ( hasNotOperand ) {
                    match = !match;
                }
            }
        });

        return match;
    }
function matchesCriteria(data, criteria) {
        data = data || {};
        criteria = criteria || {};

        var match = true;
        _.each(criteria, function (val, key) {
            var hasNotOperand = false;

            if (_.isObject(val) && val['$ne'] ) {
                hasNotOperand = true;
                val = val['$ne'];
            }
            var dataValue = getNestedValue(data, key);
            if (_.isString(val) && _.isArray(dataValue)) { // allows you to check if an array contains a value
                match = (dataValue.indexOf(val) > -1);
            }
            else {
                var vals = _.isArray(val) ? val : [val];
                if (vals.indexOf(dataValue) < 0) {
                    match = false;
                }
                if ( hasNotOperand ) {
                    match = !match;
                }
            }
        });

        return match;
    }
function matchesCriteria ( data , criteria ) { data = data || { } ; criteria = criteria || { } ; var match = true ; _ . each ( criteria , function ( val , key ) { var hasNotOperand = false ; if ( _ . isObject ( val ) && val [ '$ne' ] ) { hasNotOperand = true ; val = val [ '$ne' ] ; } var dataValue = getNestedValue ( data , key ) ; if ( _ . isString ( val ) && _ . isArray ( dataValue ) ) { // allows you to check if an array contains a value match = ( dataValue . indexOf ( val ) > - 1 ) ; } else { var vals = _ . isArray ( val ) ? val : [ val ] ; if ( vals . indexOf ( dataValue ) < 0 ) { match = false ; } if ( hasNotOperand ) { match = ! match ; } } } ) ; return match ; }
True if the given data matches the criteria. If criteria empty,
then always true

Examples

Obj: { a: 'monday', b: 'tuesday' }  Criteria: { a: 'monday' } // true
Obj: { a: 'monday', b: 'tuesday' }  Criteria: { a: 'tuesday' } // false
Obj: { a: 'monday', b: 'tuesday' }  Criteria: { c: 'monday' } // false
Obj: { a: 'monday', b: 'tuesday' }  Criteria: { a: { '$ne' : tuesday' } } // true

@param data
@param criteria
@returns {Boolean}
True if the given data matches the criteria . If criteria empty then always true