title: Passing a method to validates_format_of
body: <p>I want to do this:</p>
  
  <pre><code>validates_format_of :email, :with =&gt; email_regex
  
  def email_regex
    email_name_regex  = '[A-Z0-9_\.%\+\-]+'
    domain_head_regex = '(?:[A-Z0-9\-]+\.)+'
    domain_tld_regex  = '(?:[A-Z]{2,4}|museum|travel)'
    return /\A#{email_name_regex}@#{domain_head_regex}#{domain_tld_regex}\z/i
  end
  </code></pre>
  
  <p>but I am getting an error saying that I have to pass a regex to the validates method. I was sure youo could do something like this. 
  Am I missing a step?</p>
  
  <p>Thanks</p>