<commit_before>module JSONAPIonify::Api
  module Resource::Definitions::Params

    def self.extended(klass)
      klass.class_eval do
        extend JSONAPIonify::InheritedAttributes
        inherited_hash_attribute :param_definitions

        context(:params, readonly: true) do |context|
          should_error = false

          params = self.class.param_definitions.select do |_, v|
            v.actions.blank? || v.actions.include?(action_name)
          end

          context.request.params.replace(
            [*params.values.select(&:has_default?).map(&:default), context.request.params].reduce(:deep_merge)
          )

          required_params = params.select do |_, v|
            v.required
          end

          # Check for validity
          context.request.params.each do |k, v|
            keypath  = ParamOptions.hash_to_keypaths(k => v)[0]
            reserved = ParamOptions.reserved?(k)
            allowed  = params.keys.include? keypath
            valid    = ParamOptions.valid?(k) || v.is_a?(Hash)
            unless reserved || (allowed && valid)
              should_error = true
              error :parameter_invalid, ParamOptions.keypath_to_string(*keypath)
            end
          end

          # Check for requirement
          if (missing_params = ParamOptions.missing_parameters(context.request.params, required_params.values.map(&:keypath))).present?
            error :parameters_missing, missing_params
          end
<commit_msg>dont validate params on options<commit_after>module JSONAPIonify::Api
  module Resource::Definitions::Params

    def self.extended(klass)
      klass.class_eval do
        extend JSONAPIonify::InheritedAttributes
        inherited_hash_attribute :param_definitions

        context(:params, readonly: true) do |context|
          should_error = false

          params = self.class.param_definitions.select do |_, v|
            v.actions.blank? || v.actions.include?(action_name)
          end

          context.request.params.replace(
            [*params.values.select(&:has_default?).map(&:default), context.request.params].reduce(:deep_merge)
          )

          required_params = params.select do |_, v|
            v.required
          end

          # Check for validity
          context.request.params.each do |k, v|
            keypath  = ParamOptions.hash_to_keypaths(k => v)[0]
            reserved = ParamOptions.reserved?(k)
            allowed  = params.keys.include? keypath
            valid    = ParamOptions.valid?(k) || v.is_a?(Hash)
            unless reserved || (allowed && valid)
              should_error = true
              error :parameter_invalid, ParamOptions.keypath_to_string(*keypath)
            end
          end unless context.request.options?

          # Check for requirement
          if (missing_params = ParamOptions.missing_parameters(context.request.params, required_params.values.map(&:keypath))).present?
            error :parameters_missing, missing_params
          end

{'fraction_non_alphanumeric': 0.09560293137908062, 'fraction_numerical': 0.0006662225183211193, 'mean_word_length': 2.260586319218241, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4037736', 'n_tokens_mistral': 815, 'n_tokens_neox': 796, 'n_words': 156}