<commit_before>module BootstrapValidatorRails
  module Validators
    class Length < Validator
      def generate_data
        data = {}
        return data if unsupported?
        
        options = validator_options

        data[:bv_stringlength] = 'true'

        if options[:minimum]
          data[:bv_stringlength_min] = options[:minimum] 
        end

        if options[:maximum]
          data[:bv_stringlength_max] = options[:maximum] 
        end

        if options[:is]
          data[:bv_stringlength_minimum] = options[:is] 
          data[:bv_stringlength_maximum] = options[:is] 
          data[:bv_stringlength_message] = @record.errors.generate_message(@method) 
        end

        data
      end
    end
  end
end
<commit_msg>Add #generate_object to length validator<commit_after>module BootstrapValidatorRails
  module Validators
    class Length < Validator
      def generate_data
        data = {}
        return data if unsupported?
        
        options = validator_options

        data[:bv_stringlength] = 'true'

        if options[:minimum]
          data[:bv_stringlength_min] = options[:minimum] 
        end

        if options[:maximum]
          data[:bv_stringlength_max] = options[:maximum] 
        end

        if options[:is]
          data[:bv_stringlength_minimum] = options[:is] 
          data[:bv_stringlength_maximum] = options[:is] 
          data[:bv_stringlength_message] = @record.errors.generate_message(@method) 
        end

        data
      end

      def generate_object
        options = @validator.options

        data = {}

        data["stringLength"] = {}

        if options[:minimum]
          data["stringLength"]["min"] = options[:minimum]
        end

        if options[:maximum]
          data["stringLength"]["max"] = options[:maximum] 
        end

        if options[:is]
          data["stringLength"]["min"] = options[:is] 
          data["stringLength"]["max"] = options[:is] 
          data["stringLength"]['message'] = @record.errors.generate_message(@method) 
        end

        {method_key => {validators: data}}
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.10192578675434476, 'fraction_numerical': 0.0, 'mean_word_length': 2.174366616989568, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '5998535', 'n_tokens_mistral': 620, 'n_tokens_neox': 565, 'n_words': 117}