lib/client.js
function(methodDef, callback, params, payload) {
        // check required params
        for (var index in methodDef.required_params) {
            var requiredParamName = methodDef.required_params[index];
            if (!params.hasOwnProperty(requiredParamName)) {
                callback(requiredParamName +' param is required');
                return false;
            }
        }
        // check unattended params
        if (methodDef.unattended_params === false) {
            for (var param in params) {
                if (methodDef.optional_params.indexOf(param) == -1
                    && methodDef.required_params.indexOf(param) == -1) {
                    callback('unattended param '+ param);
                    return false;
                }
            }
        }
        // TODO: optional_payload is also on spore specification
        if (!payload && methodDef.required_payload === true) {
            callback("payload is required");
            return false;
        }
        return true;
    }
function(methodDef, callback, params, payload) {
        // check required params
        for (var index in methodDef.required_params) {
            var requiredParamName = methodDef.required_params[index];
            if (!params.hasOwnProperty(requiredParamName)) {
                callback(requiredParamName +' param is required');
                return false;
            }
        }
        // check unattended params
        if (methodDef.unattended_params === false) {
            for (var param in params) {
                if (methodDef.optional_params.indexOf(param) == -1
                    && methodDef.required_params.indexOf(param) == -1) {
                    callback('unattended param '+ param);
                    return false;
                }
            }
        }
        // TODO: optional_payload is also on spore specification
        if (!payload && methodDef.required_payload === true) {
            callback("payload is required");
            return false;
        }
        return true;
    }
function ( methodDef , callback , params , payload ) { // check required params for ( var index in methodDef . required_params ) { var requiredParamName = methodDef . required_params [ index ] ; if ( ! params . hasOwnProperty ( requiredParamName ) ) { callback ( requiredParamName + ' param is required' ) ; return false ; } } // check unattended params if ( methodDef . unattended_params === false ) { for ( var param in params ) { if ( methodDef . optional_params . indexOf ( param ) == - 1 && methodDef . required_params . indexOf ( param ) == - 1 ) { callback ( 'unattended param ' + param ) ; return false ; } } } // TODO: optional_payload is also on spore specification if ( ! payload && methodDef . required_payload === true ) { callback ( "payload is required" ) ; return false ; } return true ; }
Check params and payload
Check params and payload