<commit_before>module Prequel
  module Validations
    def validates_uniqueness_of(column_name, options={})
      column = table.get_column(column_name)
      raise "No column #{column_name.inspect} to validate the uniqueness of" unless column
      validate do
        field_value = get_field_value(column_name)
        relation = table.where(column_name => field_value)
        relation = relation.where(:id.neq(id)) if persisted?
        unless relation.empty?
          errors.add(column_name, options[:message] || "#{column_name.to_s.humanize} must be unique")
        end
      end
    end

    def validates_presence_of(column_name, options={})
      column = table.get_column(column_name)
      raise "No column #{column_name.inspect} to validate the uniqueness of" unless column
      validate do
        field_value = get_field_value(column_name)
        if field_value.blank?
          errors.add(column_name, options[:message] || "#{column_name.to_s.humanize} must not be blank")
        end
      end
    end
  end
end<commit_msg>Add validates_confirmation_of<commit_after>module Prequel
  module Validations
    def validates_uniqueness_of(column_name, options={})
      column = table.get_column(column_name)
      raise "No column #{column_name.inspect} to validate the uniqueness of" unless column
      validate do
        field_value = get_field_value(column_name)
        relation = table.where(column_name => field_value)
        relation = relation.where(:id.neq(id)) if persisted?
        unless relation.empty?
          errors.add(column_name, options[:message] || "#{column_name.to_s.humanize} must be unique")
        end
      end
    end

    def validates_presence_of(column_name, options={})
      column = table.get_column(column_name)
      raise "No column #{column_name.inspect} to validate the uniqueness of" unless column
      validate do
        field_value = get_field_value(column_name)
        if field_value.blank?
          errors.add(column_name, options[:message] || "#{column_name.to_s.humanize} must not be blank")
        end
      end
    end

    def validates_confirmation_of(attr1, options={})
      attr2 = "#{attr1}_confirmation".to_sym
      validate do
        if send(attr1) != send(attr2)
          errors.add(column_name, options[:message] || "#{attr1.humanize.capitalize} did not match #{attr2.humanize}")
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09268495428096425, 'fraction_numerical': 0.0029093931837073984, 'mean_word_length': 3.1005110732538332, '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': '4302201', 'n_tokens_mistral': 720, 'n_tokens_neox': 710, 'n_words': 172}