title: Validate Attribute without saving
body: <p>In Rails 3, I would like to see if a value for an attribute is valid using the model's <code>validates</code> options without trying to save or create.</p>
  
  <p>I'm writing the back end of a AJAX API, that should check a username against the </p>
  
  <pre><code>validates :username, :length =&gt; {:minimum =&gt; 2, :maximum =&gt; 50}, :exclusion =&gt; {:in =&gt; RESERVED_USERNAMES}, :format =&gt; MY_REGEX, .etc
  </code></pre>
  
  <p>In the User model. This it to create a little tick or cross next to the username field in the register form, so the user doesn't have to wait to see if the username is taken or not.</p>
  
  <p>I could just compare it to a regex, but to try to keep my code DRY, I thought it would be better to use the validation in the user model.</p>
  
  <p>Anyone know how I could do something of the line of:</p>
  
  <pre><code>username = params[:username]
  
  if User.not_found(:username =&gt; username) &amp;&amp; User.validate(:username =&gt; username)
      #yay!
  else
      #nope
  end
  </code></pre>
  
  <p>(I already have the <code>not_found</code> working).</p>