<commit_before># encoding: utf-8
module Mongoid #:nodoc:
  module Validations #:nodoc:
    # Validates whether or not a field is unique against the documents in the
    # database.
    #
    # Example:
    #
    #   class Person
    #     include Mongoid::Document
    #     field :title
    #
    #     validates_uniqueness_of :title
    #   end
    class UniquenessValidator < ActiveModel::EachValidator
      def validate_each(document, attribute, value)
        return if document.class.where(attribute => value, :_id.ne => document._id).empty?
        document.errors.add(attribute, :invalid, :default => options[:message], :value => value)
      end
    end
  end
end
<commit_msg>Message should be taken, not invalid<commit_after># encoding: utf-8
module Mongoid #:nodoc:
  module Validations #:nodoc:
    # Validates whether or not a field is unique against the documents in the
    # database.
    #
    # Example:
    #
    #   class Person
    #     include Mongoid::Document
    #     field :title
    #
    #     validates_uniqueness_of :title
    #   end
    class UniquenessValidator < ActiveModel::EachValidator
      def validate_each(document, attribute, value)
        return if document.class.where(attribute => value, :_id.ne => document._id).empty?
        document.errors.add(attribute, :taken, :default => options[:message], :value => value)
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09691313711414214, 'fraction_numerical': 0.0014357501794687725, 'mean_word_length': 2.7880434782608696, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '1770887', 'n_tokens_mistral': 406, 'n_tokens_neox': 404, 'n_words': 117}