mixins/snitch.js
function(obj){
        var validators = Object.clone(this._validators),
            // Store the global validator
            global = validators[asterisk], keys;

        // If global validator exists, test the object against it
        if (global) {
            // remove '*' validator from validators obj otherwise comparing keys will not pass
            delete validators[asterisk];
            
            // retrieve keys of obj for comparison;
            keys = Object.keys(obj);
            // return global(obj) && Object.every(validators, function(val, prop){ return prop in obj;});
            return global(obj) && Object.keys(validators).every( keys.contains.bind(keys) );
        } else {
            // result and Snitch.proof must return true in order to pass proofing
            return Snitch.proof(obj, validators);
        }
    }
function(obj){
        var validators = Object.clone(this._validators),
            // Store the global validator
            global = validators[asterisk], keys;

        // If global validator exists, test the object against it
        if (global) {
            // remove '*' validator from validators obj otherwise comparing keys will not pass
            delete validators[asterisk];
            
            // retrieve keys of obj for comparison;
            keys = Object.keys(obj);
            // return global(obj) && Object.every(validators, function(val, prop){ return prop in obj;});
            return global(obj) && Object.keys(validators).every( keys.contains.bind(keys) );
        } else {
            // result and Snitch.proof must return true in order to pass proofing
            return Snitch.proof(obj, validators);
        }
    }
function ( obj ) { var validators = Object . clone ( this . _validators ) , // Store the global validator global = validators [ asterisk ] , keys ; // If global validator exists, test the object against it if ( global ) { // remove '*' validator from validators obj otherwise comparing keys will not pass delete validators [ asterisk ] ; // retrieve keys of obj for comparison; keys = Object . keys ( obj ) ; // return global(obj) && Object.every(validators, function(val, prop){ return prop in obj;}); return global ( obj ) && Object . keys ( validators ) . every ( keys . contains . bind ( keys ) ) ; } else { // result and Snitch.proof must return true in order to pass proofing return Snitch . proof ( obj , validators ) ; } }
Proof the object that it has every item that this._validators has
and that every validator passes.
@param  {Object} obj        Object to validate
@return {Boolean}           The answer to whether the object passes or not
Proof the object that it has every item that this . _validators has and that every validator passes .