title: Can't validate phone number
body: <p>I'm trying to validate a phone number without success. When I submit the form for the following model, it always accepts the phone number I put in, whether it's valid or not. Why is this happening?</p>
  
  <pre><code>class Client &lt; ActiveRecord::Base
    belongs_to :salon
    belongs_to :address
    accepts_nested_attributes_for :address
    attr_accessible :address_attributes, :name, :phone, :email
    validates_presence_of :name
    validates_presence_of :email
    validates_presence_of :phone,
      :unless =&gt; Proc.new { |c| c.phone.gsub(/[^0-9]/, "").length != 10 }
  end
  </code></pre>
  
  <p>-</p>
  
  <pre><code>&lt;%= form_for(@client) do |f| %&gt;
    &lt;% if @client.errors.any? %&gt;
      &lt;div id="error_explanation"&gt;
        &lt;h2&gt;&lt;%= pluralize(@client.errors.count, "error") %&gt; prohibited this client from being saved:&lt;/h2&gt;
  
        &lt;ul&gt;
        &lt;% @client.errors.full_messages.each do |msg| %&gt;
          &lt;li&gt;&lt;%= msg %&gt;&lt;/li&gt;
        &lt;% end %&gt;
        &lt;/ul&gt;
      &lt;/div&gt;
    &lt;% end %&gt;
  
    &lt;%= f.hidden_field :salon_id, :value =&gt; Salon.logged_in_salon.id %&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :name %&gt;&lt;br /&gt;
      &lt;%= f.text_field :name %&gt;
    &lt;/div&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :phone %&gt;&lt;br /&gt;
      &lt;%= f.text_field :phone %&gt;
    &lt;/div&gt;
    &lt;div class="field"&gt;
      &lt;%= f.label :email %&gt;&lt;br /&gt;
      &lt;%= f.text_field :email %&gt;
    &lt;/div&gt;
  
    &lt;%= f.fields_for :address do |address_form| %&gt;
      &lt;div class="field"&gt;
        &lt;%= address_form.label :line1 %&gt;&lt;br /&gt;
        &lt;%= address_form.text_field :line1 %&gt;
      &lt;/div&gt;
      &lt;div class="field"&gt;
        &lt;%= address_form.label :line2 %&gt;&lt;br /&gt;
        &lt;%= address_form.text_field :line2 %&gt;
      &lt;/div&gt;
      &lt;div class="field"&gt;
        &lt;%= address_form.label :city %&gt;&lt;br /&gt;
        &lt;%= address_form.text_field :city %&gt;
      &lt;/div&gt;
      &lt;div class="field"&gt;
        &lt;%= address_form.label :state_id %&gt;&lt;br /&gt;
        &lt;%= select("client[address]", "state_id", State.all.collect {|s| [ s.name, s.id ] }) %&gt;
      &lt;/div&gt;
      &lt;div class="field"&gt;
        &lt;%= address_form.label :zip %&gt;&lt;br /&gt;
        &lt;%= address_form.text_field :zip %&gt;
      &lt;/div&gt;
    &lt;% end %&gt;
  
    &lt;div class="actions"&gt;
      &lt;%= f.submit %&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>