Sha256: 8781566d31fc888d32f4ea27786fea6394682aa8679848e6a137df23aca54117

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

class InputSanitizer::V2::QuerySanitizer < InputSanitizer::V2::PayloadSanitizer
  def self.converters
    {
      :integer => InputSanitizer::V2::Types::CoercingIntegerCheck.new,
      :float => InputSanitizer::V2::Types::CoercingFloatCheck.new,
      :string => InputSanitizer::V2::Types::StringCheck.new,
      :boolean => InputSanitizer::V2::Types::CoercingBooleanCheck.new,
      :datetime => InputSanitizer::V2::Types::DatetimeCheck.new,
      :date => InputSanitizer::V2::Types::DatetimeCheck.new(:check_date => true),
      :url => InputSanitizer::V2::Types::URLCheck.new,
    }
  end
  initialize_types_dsl

  def self.sort_by(allowed_values, options = {})
    set_keys_to_converter([:sort_by, { :allow => allowed_values }.merge(options)], InputSanitizer::V2::Types::SortByCheck.new)
  end

  # allow underscore cache buster by default
  string :_

  private
  def perform_clean
    super
    @errors.each do |error|
      error.field = error.field[1..-1] if error.field.start_with?('/')
    end
  end

  def sanitizer_type
    :query
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
input_sanitizer-0.6.0 lib/input_sanitizer/v2/query_sanitizer.rb
input_sanitizer-0.5.0 lib/input_sanitizer/v2/query_sanitizer.rb
input_sanitizer-0.4.1 lib/input_sanitizer/v2/query_sanitizer.rb
input_sanitizer-0.4.0 lib/input_sanitizer/v2/query_sanitizer.rb
input_sanitizer-0.3.33 lib/input_sanitizer/v2/query_sanitizer.rb