src/index.js
function validateValue(key, valObj, list) {
  let type; let valid; let range; let regex;

  const object = list[key];
  const val = hasKey(valObj, key) ? valObj[key] : 'value_not_defined';
  let defaultValue = object;

  if (object) {
    type = object.type;
    valid = object.valid;
    range = object.range;
    regex = object.regex;

    defaultValue = hasKey(object, 'default') ? object.default : object;
  }

  if (isDeclared(val)) {
    return defaultValue;
  }

  if (isMatch(key, val, regex)) {
    return val;
  }

  if (isValid(key, val, valid, type)) {
    return val;
  }

  isType(key, val, type);

  inRange(key, val, range);

  return val;
}
function validateValue(key, valObj, list) {
  let type; let valid; let range; let regex;

  const object = list[key];
  const val = hasKey(valObj, key) ? valObj[key] : 'value_not_defined';
  let defaultValue = object;

  if (object) {
    type = object.type;
    valid = object.valid;
    range = object.range;
    regex = object.regex;

    defaultValue = hasKey(object, 'default') ? object.default : object;
  }

  if (isDeclared(val)) {
    return defaultValue;
  }

  if (isMatch(key, val, regex)) {
    return val;
  }

  if (isValid(key, val, valid, type)) {
    return val;
  }

  isType(key, val, type);

  inRange(key, val, range);

  return val;
}
function validateValue ( key , valObj , list ) { let type ; let valid ; let range ; let regex ; const object = list [ key ] ; const val = hasKey ( valObj , key ) ? valObj [ key ] : 'value_not_defined' ; let defaultValue = object ; if ( object ) { type = object . type ; valid = object . valid ; range = object . range ; regex = object . regex ; defaultValue = hasKey ( object , 'default' ) ? object . default : object ; } if ( isDeclared ( val ) ) { return defaultValue ; } if ( isMatch ( key , val , regex ) ) { return val ; } if ( isValid ( key , val , valid , type ) ) { return val ; } isType ( key , val , type ) ; inRange ( key , val , range ) ; return val ; }
Checks if a value fits the restrictions.

@param {string} key    - The name of the option
@param {object} valObj - The value to check.
@param {object} list   - The replacement restrictions.

@returns A value, whether it is the default or the given by the user.
Checks if a value fits the restrictions .