Sha256: fb15deeddfc59066124ce45017902424af82f52c8722fcc438ebf57199ee7494

Contents?: true

Size: 573 Bytes

Versions: 11

Compression:

Stored size: 573 Bytes

Contents

# frozen_string_literal: true

module Grape
  module Validations
    module Validators
      class AllowBlankValidator < Base
        def validate_param!(attr_name, params)
          return if (options_key?(:value) ? @option[:value] : @option) || !params.is_a?(Hash)

          value = params[attr_name]
          value = value.strip if value.respond_to?(:strip)

          return if value == false || value.present?

          raise Grape::Exceptions::Validation.new(params: [@scope.full_name(attr_name)], message: message(:blank))
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
grape-2.2.0 lib/grape/validations/validators/allow_blank_validator.rb
grape-2.1.3 lib/grape/validations/validators/allow_blank_validator.rb
grape-2.1.2 lib/grape/validations/validators/allow_blank_validator.rb
grape-2.1.1 lib/grape/validations/validators/allow_blank_validator.rb
grape-2.1.0 lib/grape/validations/validators/allow_blank_validator.rb
grape-2.0.0 lib/grape/validations/validators/allow_blank_validator.rb
grape-1.8.0 lib/grape/validations/validators/allow_blank_validator.rb
grape-1.7.1 lib/grape/validations/validators/allow_blank_validator.rb
grape-1.7.0 lib/grape/validations/validators/allow_blank_validator.rb
grape-1.6.2 lib/grape/validations/validators/allow_blank.rb
grape-1.6.1 lib/grape/validations/validators/allow_blank_validator.rb