title: Trying to validate a date
body: <p>I have a form where i'm trying to validate that a field called "birthday" is not blank, and that the date is a valid date format that the Chronic gem can parse. I always get the error message "Birthday is invalid". I've been trying a simple format "10/10/2010".</p>
  
  <p>How can i validate that the birthday field is of a format that chronic can parse?</p>
  
  <p>User.rb model</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
  
    validates :birthday, :presence =&gt; true
    validate :birthday_is_date
    validate :position, :presence =&gt; true
  
    # validate the birthday format
    def birthday_is_date
      errors.add(:birthday ,Chronic.parse(birthday)) # testing to see the value of :birthday
      errors.add(:birthday, "is invalid test message") if ((Chronic.parse(:birthday) rescue ArgumentError) == ArgumentError)
    end
  end
  </code></pre>
  
  <p>contacts_controller.rb </p>
  
  <pre><code># POST /contacts/1/edit
      # actually updates the users data
      def update_user
          @userProfile = User.find(params[:id])
  
          respond_to do |format|
              if @userProfile.update_attributes(params[:user])
                  format.html {
                      flash[:success] = "Information updated successfully"
                      redirect_to(profile_path)
                  }
              else 
                  format.html {
                      flash[:error] = resource.errors.full_messages
  
                      render :edit
                  }
              end
          end
      end
  </code></pre>