From 96eaeee4467a03cba3c4c30aeb6fc6afe545ae1d Mon Sep 17 00:00:00 2001 From: Jeffrey Hardy Date: Fri, 6 Mar 2009 17:43:00 -0500 Subject: Add ActiveRecord::Base#invalid? as the opposite of #valid? [#2159 state:resolved] Signed-off-by: Pratik Naik --- activerecord/lib/active_record/validations.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 4453047daf..ba60180ae0 100644 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -1040,6 +1040,11 @@ module ActiveRecord errors.empty? end + # Performs the opposite of valid?. Returns true if errors were added, false otherwise. + def invalid? + !valid? + end + # Returns the Errors object that holds all information about attribute error messages. def errors @errors ||= Errors.new(self) -- cgit v1.2.3