<commit_before>class User < ActiveRecord::Base
  has_secure_password
  validates :password, length: { minimum: 8 }
  validate :passwords_match

  has_many :notes

  private

  def passwords_match
    if password.present? && password != password_confirmation
      errors.add :password_confirmation, 'must match the password'
    end
  end
end
<commit_msg>Enforce uniqueness of username.<commit_after>class User < ActiveRecord::Base
  has_secure_password
  validates :password, length: { minimum: 8 }
  validates :username, presence: true, uniqueness: true
  validate :passwords_match

  has_many :notes

  private

  def passwords_match
    if password.present? && password != password_confirmation
      errors.add :password_confirmation, 'must match the password'
    end
  end
end

{'fraction_non_alphanumeric': 0.07142857142857142, 'fraction_numerical': 0.002551020408163265, 'mean_word_length': 4.340136054421769, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2178832', 'n_tokens_mistral': 231, 'n_tokens_neox': 218, 'n_words': 67}