From 28f36279cd484dc66b8b0ca2f0c3d75fd9ac631c Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 8 Jun 2009 20:32:08 -0500 Subject: Properly require ActiveModel validation dependencies --- activemodel/lib/active_model/validations/acceptance.rb | 4 ++-- activemodel/lib/active_model/validations/confirmation.rb | 4 ++-- activemodel/lib/active_model/validations/exclusion.rb | 4 ++-- activemodel/lib/active_model/validations/format.rb | 4 ++-- activemodel/lib/active_model/validations/inclusion.rb | 4 ++-- activemodel/lib/active_model/validations/length.rb | 4 ++-- activemodel/lib/active_model/validations/numericality.rb | 4 ++-- activemodel/lib/active_model/validations/presence.rb | 6 ++++-- 8 files changed, 18 insertions(+), 16 deletions(-) (limited to 'activemodel/lib/active_model/validations') diff --git a/activemodel/lib/active_model/validations/acceptance.rb b/activemodel/lib/active_model/validations/acceptance.rb index 0c9ef51726..b65c9b933d 100644 --- a/activemodel/lib/active_model/validations/acceptance.rb +++ b/activemodel/lib/active_model/validations/acceptance.rb @@ -39,10 +39,10 @@ module ActiveModel validates_each(attr_names,configuration) do |record, attr_name, value| unless value == configuration[:accept] - record.errors.add(attr_name, :accepted, :default => configuration[:message]) + record.errors.add(attr_name, :accepted, :default => configuration[:message]) end end end end end -end \ No newline at end of file +end diff --git a/activemodel/lib/active_model/validations/confirmation.rb b/activemodel/lib/active_model/validations/confirmation.rb index b9823172f7..d414224dd2 100644 --- a/activemodel/lib/active_model/validations/confirmation.rb +++ b/activemodel/lib/active_model/validations/confirmation.rb @@ -36,10 +36,10 @@ module ActiveModel validates_each(attr_names, configuration) do |record, attr_name, value| unless record.send("#{attr_name}_confirmation").nil? or value == record.send("#{attr_name}_confirmation") - record.errors.add(attr_name, :confirmation, :default => configuration[:message]) + record.errors.add(attr_name, :confirmation, :default => configuration[:message]) end end end end end -end \ No newline at end of file +end diff --git a/activemodel/lib/active_model/validations/exclusion.rb b/activemodel/lib/active_model/validations/exclusion.rb index 0aa9848ee1..2cfdec97a5 100644 --- a/activemodel/lib/active_model/validations/exclusion.rb +++ b/activemodel/lib/active_model/validations/exclusion.rb @@ -29,10 +29,10 @@ module ActiveModel validates_each(attr_names, configuration) do |record, attr_name, value| if enum.include?(value) - record.errors.add(attr_name, :exclusion, :default => configuration[:message], :value => value) + record.errors.add(attr_name, :exclusion, :default => configuration[:message], :value => value) end end end end end -end \ No newline at end of file +end diff --git a/activemodel/lib/active_model/validations/format.rb b/activemodel/lib/active_model/validations/format.rb index 8efce8ba2b..6f3b668bf0 100644 --- a/activemodel/lib/active_model/validations/format.rb +++ b/activemodel/lib/active_model/validations/format.rb @@ -32,10 +32,10 @@ module ActiveModel validates_each(attr_names, configuration) do |record, attr_name, value| unless value.to_s =~ configuration[:with] - record.errors.add(attr_name, :invalid, :default => configuration[:message], :value => value) + record.errors.add(attr_name, :invalid, :default => configuration[:message], :value => value) end end end end end -end \ No newline at end of file +end diff --git a/activemodel/lib/active_model/validations/inclusion.rb b/activemodel/lib/active_model/validations/inclusion.rb index a4bc8fe035..0d7dc5cd64 100644 --- a/activemodel/lib/active_model/validations/inclusion.rb +++ b/activemodel/lib/active_model/validations/inclusion.rb @@ -29,10 +29,10 @@ module ActiveModel validates_each(attr_names, configuration) do |record, attr_name, value| unless enum.include?(value) - record.errors.add(attr_name, :inclusion, :default => configuration[:message], :value => value) + record.errors.add(attr_name, :inclusion, :default => configuration[:message], :value => value) end end end end end -end \ No newline at end of file +end diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb index bb9a269a02..db0439d447 100644 --- a/activemodel/lib/active_model/validations/length.rb +++ b/activemodel/lib/active_model/validations/length.rb @@ -81,7 +81,7 @@ module ActiveModel validates_each(attrs, options) do |record, attr, value| value = options[:tokenizer].call(value) if value.kind_of?(String) unless !value.nil? and value.size.method(validity_checks[option])[option_value] - record.errors.add(attr, key, :default => custom_message, :count => option_value) + record.errors.add(attr, key, :default => custom_message, :count => option_value) end end end @@ -90,4 +90,4 @@ module ActiveModel alias_method :validates_size_of, :validates_length_of end end -end \ No newline at end of file +end diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb index 79fca2f1ea..ada6e28594 100644 --- a/activemodel/lib/active_model/validations/numericality.rb +++ b/activemodel/lib/active_model/validations/numericality.rb @@ -71,7 +71,7 @@ module ActiveModel case option when :odd, :even unless raw_value.to_i.method(ALL_NUMERICALITY_CHECKS[option])[] - record.errors.add(attr_name, option, :value => raw_value, :default => configuration[:message]) + record.errors.add(attr_name, option, :value => raw_value, :default => configuration[:message]) end else unless raw_value.method(ALL_NUMERICALITY_CHECKS[option])[configuration[option]] @@ -83,4 +83,4 @@ module ActiveModel end end end -end \ No newline at end of file +end diff --git a/activemodel/lib/active_model/validations/presence.rb b/activemodel/lib/active_model/validations/presence.rb index 518bc8a952..72d6b1c6f0 100644 --- a/activemodel/lib/active_model/validations/presence.rb +++ b/activemodel/lib/active_model/validations/presence.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/object/blank' + module ActiveModel module Validations module ClassMethods @@ -16,7 +18,7 @@ module ActiveModel # # Configuration options: # * message - A custom error message (default is: "can't be blank"). - # * on - Specifies when this validation is active (default is :save, other options :create, + # * on - Specifies when this validation is active (default is :save, other options :create, # :update). # * if - Specifies a method, proc or string to call to determine if the validation should # occur (e.g. :if => :allow_validation, or :if => Proc.new { |user| user.signup_step > 2 }). @@ -36,4 +38,4 @@ module ActiveModel end end end -end \ No newline at end of file +end -- cgit v1.2.3