<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -11,6 +11,11 @@ module MongoMapper
         key :_id, String
         key :created_at, Time
         key :updated_at, Time
+        
+        define_callbacks  :before_create,  :after_create, 
+                          :before_update,  :after_update,
+                          :before_save,    :after_save,
+                          :before_destroy, :after_destroy
       end
     end
     </diff>
      <filename>lib/mongomapper/document.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,13 +9,6 @@ module MongoMapper
         include Validatable
         include ActiveSupport::Callbacks
         include MongoMapper::Serialization
-        
-        define_callbacks  :before_validation_on_create, :before_validation_on_update,
-                          :before_validation,           :after_validation,
-                          :before_create,               :after_create, 
-                          :before_update,               :after_update,
-                          :before_save,                 :after_save,
-                          :before_destroy,              :after_destroy
       end
     end
     </diff>
      <filename>lib/mongomapper/embedded_document.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,10 @@ module MongoMapper
       base.class_eval do
         alias_method_chain :valid?, :callbacks
         alias_method_chain :save, :validation
+        
+        define_callbacks  :before_validation_on_create,   :before_validation_on_update,
+                          :before_validation,             :after_validation,
+                          :validate, :validate_on_create, :validate_on_update
       end
     end
     
@@ -12,16 +16,34 @@ module MongoMapper
     end
     
     private
-      def save_with_validation
-        new? ? run_callbacks(:before_validation_on_create) : 
-               run_callbacks(:before_validation_on_update)
-      
-        valid? ? save_without_validation : false
+      def save_with_validation        
+        if valid?
+          save_without_validation
+        else
+          false
+        end
       end
     
       def valid_with_callbacks?
         run_callbacks(:before_validation)
-        run_callbacks(:after_validation) if valid_without_callbacks?
+        
+        if new?
+          run_callbacks(:before_validation_on_create)
+        else
+          run_callbacks(:before_validation_on_update)
+        end
+        
+        run_callbacks(:validate)
+        
+        if new?
+          run_callbacks(:validate_on_create)
+        else
+          run_callbacks(:validate_on_update)
+        end
+        
+        is_valid = valid_without_callbacks?
+        run_callbacks(:after_validation) if is_valid
+        is_valid 
       end
   end  
 end
\ No newline at end of file</diff>
      <filename>lib/mongomapper/save_with_validation.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,7 +15,8 @@ class CallbacksTest &lt; Test::Unit::TestCase
           :before_create,     :after_create, 
           :before_update,     :after_update,
           :before_save,       :after_save,
-          :before_destroy,    :after_destroy].each do |callback|
+          :before_destroy,    :after_destroy,
+          :validate, :validate_on_create, :validate_on_update].each do |callback|
           callback_method = &quot;#{callback}_callback&quot;
           send(callback, callback_method)
           define_method(callback_method) do
@@ -36,7 +37,7 @@ class CallbacksTest &lt; Test::Unit::TestCase
     
     should &quot;get the order right for creating documents&quot; do
       doc = @document.create(:name =&gt; 'John Nunemaker')
-      doc.history.should == [:before_validation_on_create, :before_validation, :after_validation, :before_save, :before_create, :after_create, :after_save]
+      doc.history.should == [:before_validation, :before_validation_on_create, :validate, :validate_on_create, :after_validation, :before_save, :before_create, :after_create, :after_save]
     end
     
     should &quot;get the order right for updating documents&quot; do
@@ -44,7 +45,7 @@ class CallbacksTest &lt; Test::Unit::TestCase
       doc.clear_history
       doc.name = 'John'
       doc.save
-      doc.history.should == [:before_validation_on_update, :before_validation, :after_validation, :before_save, :before_update, :after_update, :after_save]
+      doc.history.should == [:before_validation, :before_validation_on_update, :validate, :validate_on_update, :after_validation, :before_save, :before_update, :after_update, :after_save]
     end
     
     should &quot;work for before and after validation&quot; do</diff>
      <filename>test/test_callbacks.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>fa9e54699650629ddef059bef257185d699bb635</id>
    </parent>
  </parents>
  <author>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </author>
  <url>http://github.com/jnunemaker/mongomapper/commit/98632c92dfceb7ada62f4fd00c201e3fd5956cf5</url>
  <id>98632c92dfceb7ada62f4fd00c201e3fd5956cf5</id>
  <committed-date>2009-07-03T15:12:13-07:00</committed-date>
  <authored-date>2009-07-03T15:12:13-07:00</authored-date>
  <message>Straightened out callbacks and added validate, validate_on_create and validate_on_update.</message>
  <tree>02586a06363f8ce94323d8093f6c7aaa790b9d24</tree>
  <committer>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </committer>
</commit>
