debian-mirror-gitlab/lib/api/validations/validators/array_none_any.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
593 B
Ruby
Raw Normal View History

2020-04-22 19:07:51 +05:30
# 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) ||
2023-03-04 22:38:38 +05:30
[IssuableFinder::Params::FILTER_NONE, IssuableFinder::Params::FILTER_ANY].include?(value.to_s.downcase)
2020-04-22 19:07:51 +05:30
2021-02-22 17:27:13 +05:30
raise Grape::Exceptions::Validation.new(
params: [@scope.full_name(attr_name)],
message: "should be an array, 'None' or 'Any'"
)
2020-04-22 19:07:51 +05:30
end
end
end
end
end