Sha256: c7a037923ec32d142132098b34eebd7e4712777fae79bd3f3128dc61111953e2

Contents?: true

Size: 490 Bytes

Versions: 11

Compression:

Stored size: 490 Bytes

Contents

module Grape
  module Validations
    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, params: [@scope.full_name(attr_name)], message: message(:blank)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.2.5/lib/grape/validations/validators/allow_blank.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/grape-1.2.5/lib/grape/validations/validators/allow_blank.rb
grape-1.2.5 lib/grape/validations/validators/allow_blank.rb
grape-1.2.4 lib/grape/validations/validators/allow_blank.rb
grape-1.2.3 lib/grape/validations/validators/allow_blank.rb
grape-1.2.2 lib/grape/validations/validators/allow_blank.rb
grape-1.2.1 lib/grape/validations/validators/allow_blank.rb
grape-1.2.0 lib/grape/validations/validators/allow_blank.rb
grape-1.1.0 lib/grape/validations/validators/allow_blank.rb
grape-1.0.3 lib/grape/validations/validators/allow_blank.rb
grape-1.0.2 lib/grape/validations/validators/allow_blank.rb