title: Raise validation error from virtual attribute in Rails
body: <p>I got two models: Source and SourceType. Source of course belongs to SourceType.<br/>
  I want to create new source and assign proper sourcetype object to it. 'Proper' means that one virtual attribute of the source object match some of sourceType objects test regexpression, which becomes source's Type.<br/></p>
  
  <p>I got an attribute writer in source object</p>
  
  <pre><code>class Source &lt; ActiveRecord::Base
     belongs_to :source_type    
     def url=(value)
         SourceType.each do |type|
            # here i match type's regexp to input value and if match, 
            # assign it to the new source object
         end
     end
  end
  </code></pre>
  
  <p>I don't want to build any custom validator for it'll be need to run through SourceTypes twice. How to raise validate error if no sourcetypes is fit to the input so user could see error reasons in a form?</p>