Sha256: 432d16f992561cd779b1b3dc090a79be1dabd4896d23586bd022036d2f66256c

Contents?: true

Size: 430 Bytes

Versions: 3

Compression:

Stored size: 430 Bytes

Contents

module Grape
  module Validations
    class PresenceValidator < Base
      def validate!(params)
        return unless @scope.should_validate?(params)
        super
      end

      def validate_param!(attr_name, params)
        return if params.respond_to?(:key?) && params.key?(attr_name)
        fail Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: message(:presence)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
grape-0.16.2 lib/grape/validations/validators/presence.rb
grape-0.16.1 lib/grape/validations/validators/presence.rb
grape-0.15.0 lib/grape/validations/validators/presence.rb