<commit_before>class User < ActiveRecord::Base  
  VALID_PLATE_REGEX = /\A[1-9][0-9][0-9][a-z][a-z][a-z]\z/i
  validates :plate, presence: true, format: { with: VALID_PLATE_REGEX }

  validates :via, presence: true
  validates_inclusion_of :via, in: %w(EMAIL PHONE)  

  validates :destination, presence: true
  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  validates :destination, format: { with: VALID_EMAIL_REGEX }, if: lambda { self.via == 'EMAIL' }
  VALID_PHONE_REGEX = /\A[0-9]{10}\z/i
  validates :destination, format: { with: VALID_PHONE_REGEX }, if: lambda { self.via == 'PHONE' }

  before_validation {
    self.plate = self.plate.gsub(/[^0-9a-z ]/i, '').strip if self.plate
    if self.destination
      self.destination = self.destination.strip if self.via == 'EMAIL'
      self.destination = self.destination.gsub(/[^0-9]/, "") if self.via == 'PHONE'
    end
  }

  before_save {
    self.plate = self.plate.upcase
    self.destination = self.destination.downcase
  }

  has_many :settings
end<commit_msg>destino por via telefonica puede ser de 10 u 11 digitos, close #155<commit_after>class User < ActiveRecord::Base  
  VALID_PLATE_REGEX = /\A[1-9][0-9][0-9][a-z][a-z][a-z]\z/i
  validates :plate, presence: true, format: { with: VALID_PLATE_REGEX }

  validates :via, presence: true
  validates_inclusion_of :via, in: %w(EMAIL PHONE)  

  validates :destination, presence: true
  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  validates :destination, format: { with: VALID_EMAIL_REGEX }, if: lambda { self.via == 'EMAIL' }
  VALID_PHONE_REGEX = /\A[0-9]{10,11}\z/i
  validates :destination, format: { with: VALID_PHONE_REGEX }, if: lambda { self.via == 'PHONE' }

  before_validation {
    self.plate = self.plate.gsub(/[^0-9a-z ]/i, '').strip if self.plate
    if self.destination
      self.destination = self.destination.strip if self.via == 'EMAIL'
      self.destination = self.destination.gsub(/[^0-9]/, "") if self.via == 'PHONE'
    end
  }

  before_save {
    self.plate = self.plate.upcase
    self.destination = self.destination.downcase
  }

  has_many :settings
end
{'fraction_non_alphanumeric': 0.16925978312116927, 'fraction_numerical': 0.017444601603017446, 'mean_word_length': 3.4673684210526314, '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': '721015', 'n_tokens_mistral': 850, 'n_tokens_neox': 802, 'n_words': 161}