Sha256: 29f53581255549507b0164df9870c9a9d69976769967bcd36473cda78f11a864

Contents?: true

Size: 435 Bytes

Versions: 1

Compression:

Stored size: 435 Bytes

Contents

module Grape
  module Validations
    class ValuesValidator < Validator
      def initialize(attrs, options, required, scope)
        @values = options
        super
      end

      def validate_param!(attr_name, params)
        if params[attr_name] && !@values.include?(params[attr_name])
          raise Grape::Exceptions::Validation, param: @scope.full_name(attr_name), message_key: :values
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grape-0.6.1 lib/grape/validations/values.rb