validate parameters
npm i dan-nl/validate-parameters/**
 * @param {*} param
 * @param {string} [key]
 *
 * @returns {Validate}
 */
function validate( param, key )var validate = require( 'validate-parameters' )
// returns true
validate( 'test string' ).isString()
// returns `test string`
validate( 'test string' ).get().isString()
// returns fallback value `fallback string`
validate( {} ).get().isString() || 'fallback string'
// throws an Error
validate( {} ).required().isString()
// throws an Error stating the name of the parameter
validate( 0, 'mystring' ).required().isString()var validate = require( 'validate-parameters' )
var params = {
  mystring: 'my string',
  mydimmension: {
    mystring: 'my string'
  }
}
// returns true
validate( 'test string' ).isString()
// returns `test string`
validate( 'test string' ).get().isString()
// returns fallback value `fallback string`
validate( {} ).get().isString() || 'fallback string'
// throws an Error
validate( {} ).required().isString()sets whether or not the param is required.
if required and the validator evaluates to false, an Error will be thrown.
sets whether or not to return the param value. returns the param value unless the validator evaluates to false in which case false will be returned.
- isArray
- isBool
- isDate
- isFloat
- isInt
- isNull
- isObject
- isObjectLiteral
- isString
- isValidDate