<commit_before>class UsernameNotReservedValidator < ActiveModel::EachValidator
  require 'username_not_reserved_validator/reserved_names'

  @@default_options = {}

  def self.default_options
    @@default_options
  end

  def validate_each(record, attribute, value)
    options = @@default_options.merge(self.options)
    additional_reserved_names = options[:additional_reserved_names] || []
    words = ReservedNames.list + additional_reserved_names

    if (words + words.map { |w| w.pluralize} ).include?(value)
      record.errors[attribute] << (options[:message] || :invalid)<commit_msg>set default to ignore case when validation<commit_after>class UsernameNotReservedValidator < ActiveModel::EachValidator
  require 'username_not_reserved_validator/reserved_names'

  @@default_options = { case_insencitive: true }

  def self.default_options
    @@default_options
  end

  def validate_each(record, attribute, value)
    options = @@default_options.merge(self.options)
    additional_reserved_names = options[:additional_reserved_names] || []
    words = ReservedNames.list + additional_reserved_names
    words += words.map(&:pluralize)

    if options[:case_insencitive]
      words.map!(&:downcase)
      username = value.downcase
    else
      username = value
    end

    if words.include?(username)
      record.errors[attribute] << (options[:message] || :invalid)
{'fraction_non_alphanumeric': 0.10217391304347827, 'fraction_numerical': 0.0, 'mean_word_length': 4.851694915254237, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, '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': '4808595', 'n_tokens_mistral': 409, 'n_tokens_neox': 384, 'n_words': 74}