title: How to validate presence and regex format in rails controller?
body: <p>I am trying to validate an email address.. whether it is present or not.. and whether it meets a regex criteria (/xyz/). I really need to do this on the controller or view level in rails as I am going to be dumping ActiveRecord for my app as I am planning on using a nosql database later. </p>
  
  <p>Any hints? Suggestions?</p>
  
  <p>In the model, it would be the following code.. but I'm trying to do this in controller or view:</p>
  
  <pre><code>VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  
    validates :email, presence: true, 
                      format: { with: VALID_EMAIL_REGEX }, 
                      uniqueness: { case_sensitive: false }
  </code></pre>