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

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

16 lines
410 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 Absence < Grape::Validations::Base
def validate_param!(attr_name, params)
return if params.respond_to?(:key?) && !params.key?(attr_name)
2021-02-22 17:27:13 +05:30
raise Grape::Exceptions::Validation.new(params: [@scope.full_name(attr_name)], message: message(:absence))
2020-04-22 19:07:51 +05:30
end
end
end
end
end