lib/database/query.js
function validateProp(key, value) {
  const type = typeof value;

  switch (key) {
  case 'orderByKey':
  case 'orderByPriority':
  case 'orderByValue':
    if (!value) {
      throw new Error(`"query.${key}" should not be set to false. Set it off by setting an other order.`);
    }
    break;

  case 'orderByChild':
    if (value == null) {
      throw new Error('"query.orderByChild" should not be set to null. Set it off by setting an other order.');
    }
    if (type !== 'string') {
      throw new Error('"query.orderByChild" should be a string or null.');
    }
    break;

  case 'startAt':
  case 'endAt':
  case 'equalTo':
    if (
      value !== null &&
      type !== 'string' &&
      type !== 'number' &&
      type !== 'boolean'
    ) {
      throw new Error(`query.${key} should be a string, a number, a boolean or null.`);
    }
    break;

  case 'limitToFirst':
  case 'limitToLast':
    if (value != null && type !== 'number') {
      throw new Error(`query.${key} should be a number or null.`);
    }
    break;

  default:
    throw new Error(`"${key}" is not a query parameter.`);
  }
}
function validateProp(key, value) {
  const type = typeof value;

  switch (key) {
  case 'orderByKey':
  case 'orderByPriority':
  case 'orderByValue':
    if (!value) {
      throw new Error(`"query.${key}" should not be set to false. Set it off by setting an other order.`);
    }
    break;

  case 'orderByChild':
    if (value == null) {
      throw new Error('"query.orderByChild" should not be set to null. Set it off by setting an other order.');
    }
    if (type !== 'string') {
      throw new Error('"query.orderByChild" should be a string or null.');
    }
    break;

  case 'startAt':
  case 'endAt':
  case 'equalTo':
    if (
      value !== null &&
      type !== 'string' &&
      type !== 'number' &&
      type !== 'boolean'
    ) {
      throw new Error(`query.${key} should be a string, a number, a boolean or null.`);
    }
    break;

  case 'limitToFirst':
  case 'limitToLast':
    if (value != null && type !== 'number') {
      throw new Error(`query.${key} should be a number or null.`);
    }
    break;

  default:
    throw new Error(`"${key}" is not a query parameter.`);
  }
}
function validateProp ( key , value ) { const type = typeof value ; switch ( key ) { case 'orderByKey' : case 'orderByPriority' : case 'orderByValue' : if ( ! value ) { throw new Error ( ` ${ key } ` ) ; } break ; case 'orderByChild' : if ( value == null ) { throw new Error ( '"query.orderByChild" should not be set to null. Set it off by setting an other order.' ) ; } if ( type !== 'string' ) { throw new Error ( '"query.orderByChild" should be a string or null.' ) ; } break ; case 'startAt' : case 'endAt' : case 'equalTo' : if ( value !== null && type !== 'string' && type !== 'number' && type !== 'boolean' ) { throw new Error ( ` ${ key } ` ) ; } break ; case 'limitToFirst' : case 'limitToLast' : if ( value != null && type !== 'number' ) { throw new Error ( ` ${ key } ` ) ; } break ; default : throw new Error ( ` ${ key } ` ) ; } }
Validate a query property

@param {string} key Property name
@param {any} value Property value
Validate a query property