<commit_before>class Domain < ActiveRecord::Base

  # relationships
  ###############

  belongs_to :owner, :polymorphic => true

  # validations
  #############

  # <tt>name</tt> must be a sequence of word characters (a to z, plus 0 to 9,
  # plus '_'). Letters must be lowercase
  validates_format_of :name, :with => /^([a-z0-9_-]+\.)+[a-z0-9_-]+$/, :message => N_('%{fn} must be composed only of lowercase latters (a to z), numbers (0 to 9), "_" and "-"').fix_i18n

  # checks validations that could not be expressed using Rails' predefined
  # validations. In particular:
  # * <tt>name</tt> must not start with 'www.'
  def validate
    if self.name =~ /^www\./
      self.errors.add(:name, _('%{fn} must not start with www.').fix_i18n)
    end
  end

  # we cannot have two domains with the same name
  validates_uniqueness_of :name

  # businessl logic<commit_msg>Fix for domain name checkin (accepts single words now)<commit_after>class Domain < ActiveRecord::Base

  # relationships
  ###############

  belongs_to :owner, :polymorphic => true

  # validations
  #############

  # <tt>name</tt> must be sequences of alphanumeric characters (a to z, 
  # 0 to 9), plus '_' or '-', separated by dots. Letters must be lowercase.
  validates_format_of :name, :with => /^([a-z0-9_-]+\.)+[a-z0-9_-]+$/, :message => N_('%{fn} must be composed of sequences of lowercase letters (a to z), numbers (0 to 9), "_" and "-", separated by dots.').fix_i18n

  # checks validations that could not be expressed using Rails' predefined
  # validations. In particular:
  # * <tt>name</tt> must not start with 'www.'
  def validate
    if self.name =~ /^www\./
      self.errors.add(:name, _('%{fn} must not start with www.').fix_i18n)
    end
  end

  # we cannot have two domains with the same name
  validates_uniqueness_of :name

  # businessl logic
{'fraction_non_alphanumeric': 0.16223548562126966, 'fraction_numerical': 0.013022246337493217, 'mean_word_length': 3.519607843137255, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '1315176', 'n_tokens_mistral': 642, 'n_tokens_neox': 604, 'n_words': 208}