aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/validations.rb
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-06-16 11:30:37 -0400
committerJosé Valim <jose.valim@gmail.com>2010-06-19 17:59:52 +0200
commit51739d3228d12907d60fb1b0a2b1ef96c55f66a3 (patch)
tree428364caab82ea2cfd5f320f5074bf3646b332a2 /activemodel/lib/active_model/validations.rb
parent312f43324159fbcd8749cd331ed7d6500a714a83 (diff)
downloadrails-51739d3228d12907d60fb1b0a2b1ef96c55f66a3.tar.gz
rails-51739d3228d12907d60fb1b0a2b1ef96c55f66a3.tar.bz2
rails-51739d3228d12907d60fb1b0a2b1ef96c55f66a3.zip
moving before_validation and after_validation functionality from ActiveRecord to ActiveModel
[#4653 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activemodel/lib/active_model/validations.rb')
-rw-r--r--activemodel/lib/active_model/validations.rb14
1 files changed, 2 insertions, 12 deletions
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb
index 57487cf75a..31516dc8a9 100644
--- a/activemodel/lib/active_model/validations.rb
+++ b/activemodel/lib/active_model/validations.rb
@@ -3,6 +3,7 @@ require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/class/attribute'
require 'active_support/core_ext/hash/keys'
require 'active_model/errors'
+require 'active_model/validations/callbacks'
module ActiveModel
@@ -45,6 +46,7 @@ module ActiveModel
module Validations
extend ActiveSupport::Concern
include ActiveSupport::Callbacks
+ include ActiveModel::Validations::Callbacks
included do
extend ActiveModel::Translation
@@ -158,18 +160,6 @@ module ActiveModel
@errors ||= Errors.new(self)
end
- # Runs all the specified validations and returns true if no errors were added
- # otherwise false. Context can optionally be supplied to define which callbacks
- # to test against (the context is defined on the validations using :on).
- def valid?(context = nil)
- current_context, self.validation_context = validation_context, context
- errors.clear
- _run_validate_callbacks
- errors.empty?
- ensure
- self.validation_context = current_context
- end
-
# Performs the opposite of <tt>valid?</tt>. Returns true if errors were added,
# false otherwise.
def invalid?(context = nil)