lib/search.js
function(params) {

  if (!params) {
    return {
      error: 'params cannot be null.'
    };
  }

  // query is mandatory
  if (!params.hasOwnProperty('query')) {
    return {
      error: 'query param required.'
    };
  }

  if (!validator.isString(params.query)) {
    return {
      error: 'query must be a string.'
    };
  }

  if (!validator.isValidType(params)) {
    return {
      error: 'type must be: movie, series, episode.'
    };
  }

  if (params.hasOwnProperty('year') && !validator.isNumber(params.year)) {
    return { 
      error: 'year must be a valid number'
    };
  }

}
function(params) {

  if (!params) {
    return {
      error: 'params cannot be null.'
    };
  }

  // query is mandatory
  if (!params.hasOwnProperty('query')) {
    return {
      error: 'query param required.'
    };
  }

  if (!validator.isString(params.query)) {
    return {
      error: 'query must be a string.'
    };
  }

  if (!validator.isValidType(params)) {
    return {
      error: 'type must be: movie, series, episode.'
    };
  }

  if (params.hasOwnProperty('year') && !validator.isNumber(params.year)) {
    return { 
      error: 'year must be a valid number'
    };
  }

}
function ( params ) { if ( ! params ) { return { error : 'params cannot be null.' } ; } // query is mandatory if ( ! params . hasOwnProperty ( 'query' ) ) { return { error : 'query param required.' } ; } if ( ! validator . isString ( params . query ) ) { return { error : 'query must be a string.' } ; } if ( ! validator . isValidType ( params ) ) { return { error : 'type must be: movie, series, episode.' } ; } if ( params . hasOwnProperty ( 'year' ) && ! validator . isNumber ( params . year ) ) { return { error : 'year must be a valid number' } ; } }
Validate the parameters for the search request.

@param {Object} params
@return {Object} validation state
@api private
Validate the parameters for the search request .