def bad_params?(params, required, optional = nil)
    required.each {|r|
      next if params[r]
      reply.json(400, error: 'invalid_request', error_description: "no #{r} in request")
      return true
    }
    return false unless optional
    params.each {|k, v|
      next if required.include?(k) || optional.include?(k)
      reply.json(400, error: 'invalid_request', error_description: "#{k} not allowed")
      return true
    }
    false
  end
def bad_params?(params, required, optional = nil)
    required.each {|r|
      next if params[r]
      reply.json(400, error: 'invalid_request', error_description: "no #{r} in request")
      return true
    }
    return false unless optional
    params.each {|k, v|
      next if required.include?(k) || optional.include?(k)
      reply.json(400, error: 'invalid_request', error_description: "#{k} not allowed")
      return true
    }
    false
  end
def bad_params? ( params , required , optional = nil ) required . each { | r | next if params [ r ] reply . json ( 400 , error : 'invalid_request' , error_description : "no #{r} in request" ) return true } return false unless optional params . each { | k , v | next if required . include? ( k ) || optional . include? ( k ) reply . json ( 400 , error : 'invalid_request' , error_description : "#{k} not allowed" ) return true } false end
if required and optional arrays are given, extra params are an error
if required and optional arrays are given extra params are an error