title: How should my Rails before_validation callbacks handle bad data?
body: <p>I have several before_validation callbacks that operate on the attributes being set on my model. I run into trouble when I have a situation like this:</p>
  
  <pre><code>class Foo &lt; ActiveRecord::Base
  
    before_validation :capitalize_title
    validates :title, :presence =&gt; true
  
    def capitalize_title
      title.upcase
    end
  
  end
  </code></pre>
  
  <p>I write a test to ensure that 'nil' title is not allowed, but the test gets an error because the nil.upcase is not defined. I'd like to handle this error, but I already have error handling that runs after before_validation callbacks.</p>
  
  <p>I don't want to put checks around all of my before_validation callbacks to make sure the data exists, if I can avoid it.</p>
  
  <p>Is there a clean or accepted way to deal with this type of situation?</p>