lib/couch_potato/persistence/validation.rb in couch_potato-0.2.12 vs lib/couch_potato/persistence/validation.rb in couch_potato-0.2.13
- old
+ new
@@ -6,11 +6,17 @@
def self.included(base)
base.send :include, Validatable
base.class_eval do
# Override the validate method to first run before_validation callback
def valid?
- self.run_callbacks :before_validation
+ errors.clear
+ run_callbacks :before_validation
+ before_validation_errors = errors.errors.dup
super
+ before_validation_errors.each do |k, v|
+ v.each {|message| errors.add(k, message)}
+ end
+ errors.empty?
end
end
end
end
end
\ No newline at end of file