Sha256: 76724666503775cd62235f6fb21f56b909abf21e22023d134a97c53796a5ff9c

Contents?: true

Size: 560 Bytes

Versions: 10

Compression:

Stored size: 560 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Core
    class BaseInputSort < GraphQL::Schema::InputObject
      # Overwrite the prepare method to allow 2 possible values only
      def prepare
        arguments.each do |key, value|
          next if key == "locale"
          raise GraphQL::ExecutionError, "Invalid order value for #{key}, only ASC or DESC are valids" unless valid_order?(value)
        end
        super
      end

      private

      def valid_order?(order)
        %w(asc desc).include? order.downcase
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
decidim-core-0.23.6 app/types/decidim/core/base_input_sort.rb
decidim-core-0.23.5 app/types/decidim/core/base_input_sort.rb
decidim-core-0.23.4 app/types/decidim/core/base_input_sort.rb
decidim-core-0.23.3 app/types/decidim/core/base_input_sort.rb
decidim-core-0.23.2 app/types/decidim/core/base_input_sort.rb
decidim-core-0.23.1 app/types/decidim/core/base_input_sort.rb
decidim-core-0.23.1.rc1 app/types/decidim/core/base_input_sort.rb
decidim-core-0.23.0 app/types/decidim/core/base_input_sort.rb
decidim-core-0.22.0 app/types/decidim/core/base_input_sort.rb
decidim-core-0.21.0 app/types/decidim/core/base_input_sort.rb