<commit_before>class User < ActiveRecord::Base
  acts_as_authentic do |c|
    c.transition_from_crypto_providers = Authlogic::CryptoProviders::Sha512
    c.crypto_provider = Authlogic::CryptoProviders::BCrypt
  end
  
  attr_accessible(:username, :email, :password, :password_confirmation,
                  :name, :address, :telephone, :fax)

  has_many :studies
end<commit_msg>Added some validations for users.<commit_after>class User < ActiveRecord::Base
  acts_as_authentic do |c|
    c.transition_from_crypto_providers = Authlogic::CryptoProviders::Sha512
    c.crypto_provider = Authlogic::CryptoProviders::BCrypt
  end
  
  attr_accessible(:username, :email, :password, :password_confirmation,
                  :name, :address, :telephone, :fax)

  # -- patterns for checking phone numbers
  SEP   = /( |-)?/
  WORLD = / \+\d{1,3} #{SEP} (\d|\(\d\)) #{SEP} \d{1,5} /xo
  AREA  = / \d{2,6} | \(\d{2,6}\) /xo
  LINE  = / \d{2,4} #{SEP} \d{4} /xo
  EXT   = /#{SEP}(ext|x)#{SEP}\d{1,5}/xo
  PHONE = /\A (#{WORLD}|#{AREA}) #{SEP} #{LINE} #{EXT}? \Z/xo

  validates_presence_of :name
  validates_presence_of :address
  validates_format_of   :telephone, :with => PHONE,
                        :message => "should look like a phone number"
  validates_format_of   :fax, :with => PHONE,
                        :message => "should look like a phone number"

  has_many :studies
end
{'fraction_non_alphanumeric': 0.15133960897900073, 'fraction_numerical': 0.013758146270818247, 'mean_word_length': 3.2919254658385095, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '463916', 'n_tokens_mistral': 525, 'n_tokens_neox': 498, 'n_words': 104}