lib/helpers/json-schema.js
function getValueToValidate (schema, value) {
  // Is the value empty?
  if (value === undefined || value === "" ||
    (schema.type === "object" && _.isObject(value) && _.isEmpty(value))) {

    // It's blank, so return the default/example value (if there is one)
    if (schema.default !== undefined) {
      value = schema.default;
    }
    else if (schema.example !== undefined) {
      value = schema.example;
    }
  }

  // Special case for Buffers
  if (value && value.type === "Buffer" && _.isArray(value.data)) {
    value = new Buffer(value.data);
  }

  // It's not empty, so return the existing value
  return value;
}
function getValueToValidate (schema, value) {
  // Is the value empty?
  if (value === undefined || value === "" ||
    (schema.type === "object" && _.isObject(value) && _.isEmpty(value))) {

    // It's blank, so return the default/example value (if there is one)
    if (schema.default !== undefined) {
      value = schema.default;
    }
    else if (schema.example !== undefined) {
      value = schema.example;
    }
  }

  // Special case for Buffers
  if (value && value.type === "Buffer" && _.isArray(value.data)) {
    value = new Buffer(value.data);
  }

  // It's not empty, so return the existing value
  return value;
}
function getValueToValidate ( schema , value ) { // Is the value empty? if ( value === undefined || value === "" || ( schema . type === "object" && _ . isObject ( value ) && _ . isEmpty ( value ) ) ) { // It's blank, so return the default/example value (if there is one) if ( schema . default !== undefined ) { value = schema . default ; } else if ( schema . example !== undefined ) { value = schema . example ; } } // Special case for Buffers if ( value && value . type === "Buffer" && _ . isArray ( value . data ) ) { value = new Buffer ( value . data ) ; } // It's not empty, so return the existing value return value ; }
Returns the given value, or the default value if the given value is empty.
Returns the given value or the default value if the given value is empty .