2020-04-02 08:08:18 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Validations
|
|
|
|
module Validators
|
|
|
|
class ArrayNoneAny < Grape::Validations::Base
|
|
|
|
def validate_param!(attr_name, params)
|
|
|
|
value = params[attr_name]
|
|
|
|
|
|
|
|
return if value.is_a?(Array) ||
|
|
|
|
[IssuableFinder::Params::FILTER_NONE, IssuableFinder::Params::FILTER_ANY].include?(value.to_s.downcase)
|
|
|
|
|
2020-12-10 07:09:43 -05:00
|
|
|
raise Grape::Exceptions::Validation.new(
|
|
|
|
params: [@scope.full_name(attr_name)],
|
|
|
|
message: "should be an array, 'None' or 'Any'"
|
|
|
|
)
|
2020-04-02 08:08:18 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|