validateParams.js
function(value, options){
        // make sure the default options object exists
        if(typeof this.options !== 'object') this.options = {};
        
        // build up a base config from the pre-defined defaults
        var config = { rejectUndefined: true };
        config.message = validateParams.extractValidatorMessage(this, options);
        
        // interpret the passed value
        if(typeof options === 'boolean'){
            // false prevents the validator from being run, so must have be true
            config.rejectUndefined = true;
        }else if(validate.isObject(options)){
            if(options.rejectUndefined) config.rejectUndefined = true;
            if(validate.isString(options.message)) config.message = options.message;
        }else{
            throw new Error('invalid options passed - must be true or a plain object');
        }
        
        // do the actual validation
        var errors = [];
        if(config.rejectUndefined && typeof value === 'undefined'){
            errors.push('cannot be undefined');
        }
        
        // return as appropriate
        if(errors.length > 0){
            return config.message ? config.message : errors;
        }
        return undefined;
    }
function(value, options){
        // make sure the default options object exists
        if(typeof this.options !== 'object') this.options = {};
        
        // build up a base config from the pre-defined defaults
        var config = { rejectUndefined: true };
        config.message = validateParams.extractValidatorMessage(this, options);
        
        // interpret the passed value
        if(typeof options === 'boolean'){
            // false prevents the validator from being run, so must have be true
            config.rejectUndefined = true;
        }else if(validate.isObject(options)){
            if(options.rejectUndefined) config.rejectUndefined = true;
            if(validate.isString(options.message)) config.message = options.message;
        }else{
            throw new Error('invalid options passed - must be true or a plain object');
        }
        
        // do the actual validation
        var errors = [];
        if(config.rejectUndefined && typeof value === 'undefined'){
            errors.push('cannot be undefined');
        }
        
        // return as appropriate
        if(errors.length > 0){
            return config.message ? config.message : errors;
        }
        return undefined;
    }
function ( value , options ) { // make sure the default options object exists if ( typeof this . options !== 'object' ) this . options = { } ; // build up a base config from the pre-defined defaults var config = { rejectUndefined : true } ; config . message = validateParams . extractValidatorMessage ( this , options ) ; // interpret the passed value if ( typeof options === 'boolean' ) { // false prevents the validator from being run, so must have be true config . rejectUndefined = true ; } else if ( validate . isObject ( options ) ) { if ( options . rejectUndefined ) config . rejectUndefined = true ; if ( validate . isString ( options . message ) ) config . message = options . message ; } else { throw new Error ( 'invalid options passed - must be true or a plain object' ) ; } // do the actual validation var errors = [ ] ; if ( config . rejectUndefined && typeof value === 'undefined' ) { errors . push ( 'cannot be undefined' ) ; } // return as appropriate if ( errors . length > 0 ) { return config . message ? config . message : errors ; } return undefined ; }
A validator for rejecting undefined values. Effectively a stricter
version of the `presence` validator bundled with validate.js.

This validator supports the following options in addition to the standard
`message` option:
* `rejectUndefined` - a truthy value will reject undefined values, all
all other values will accpet any value, including `undefined`.

When used in a constraint, this validator supports the following values:
* A plain object specifying options.
* `true` - a shortcut for `{ rejectUndefined: true }`

@member
@type {Validator}
@see [The Presence Validator from validate.js]{@link https://validatejs.org/#validators-presence}
@since version 1.1.1
@example <caption>A single required first parameter that can have any value</caption>
validateParams.assert(arguments, [{defined: true}]);
@example <caption>A single required first parameter that can have any value with a custom message</caption>
validateParams.assert(arguments, [{
defined: {
rejectUndefined: true,
message: 'is absolutely required'
}
}]);
A validator for rejecting undefined values . Effectively a stricter version of the presence validator bundled with validate . js .