validateParams.js
function(value, options){
        var typeVal = typeof value;
        
        // if we already have a number that's not NaN, return it unaltered
        if(typeVal === 'number' && !isNaN(value)) return value;
        
        // otherwise, try do a conversion
        var numVal = NaN;
        if(typeVal === 'string' || typeVal === 'boolean'){
            numVal = Number(value);
        }
        
        // return as appropriate, perhaps converting NaN to zero
        if(validate.isObject(options) && options.NaNToZero && isNaN(numVal)){
            return 0;
        }
        return numVal;
    }
function(value, options){
        var typeVal = typeof value;
        
        // if we already have a number that's not NaN, return it unaltered
        if(typeVal === 'number' && !isNaN(value)) return value;
        
        // otherwise, try do a conversion
        var numVal = NaN;
        if(typeVal === 'string' || typeVal === 'boolean'){
            numVal = Number(value);
        }
        
        // return as appropriate, perhaps converting NaN to zero
        if(validate.isObject(options) && options.NaNToZero && isNaN(numVal)){
            return 0;
        }
        return numVal;
    }
function ( value , options ) { var typeVal = typeof value ; // if we already have a number that's not NaN, return it unaltered if ( typeVal === 'number' && ! isNaN ( value ) ) return value ; // otherwise, try do a conversion var numVal = NaN ; if ( typeVal === 'string' || typeVal === 'boolean' ) { numVal = Number ( value ) ; } // return as appropriate, perhaps converting NaN to zero if ( validate . isObject ( options ) && options . NaNToZero && isNaN ( numVal ) ) { return 0 ; } return numVal ; }
A coercion for converting any arbitrary value to a number.

If a given value already is a number it is passed un-altered. Otherwise,
if it has a `typeof` of `string` or `boolean` an attempt will be made
to convert the value to a number with JavaScript's `Number()` function.
Other values are converted to `NaN`.

If the coercion option `NaNToZero` is set to a truthy value, then `0`
will be returned instead of `NaN` if the returned value would otherwise
be `NaN`.

@member
@type {CoercionCallback}
A coercion for converting any arbitrary value to a number .