From 8620bf90c5e486e1ec44b9aabb63f8c848668ed2 Mon Sep 17 00:00:00 2001 From: Bogdan Gusiev Date: Wed, 17 Aug 2011 17:26:00 +0300 Subject: Implemented strict validation concept In order to deliver debug information to dev team instead of display error message to end user Implemented strict validation concept that suppose to define validation that always raise exception when fails --- activemodel/lib/active_model/validations/with.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'activemodel/lib/active_model/validations/with.rb') diff --git a/activemodel/lib/active_model/validations/with.rb b/activemodel/lib/active_model/validations/with.rb index a87b213fe4..83aae206a6 100644 --- a/activemodel/lib/active_model/validations/with.rb +++ b/activemodel/lib/active_model/validations/with.rb @@ -61,7 +61,9 @@ module ActiveModel # (e.g. :unless => :skip_validation, or # :unless => Proc.new { |user| user.signup_step <= 2 }). # The method, proc or string should return or evaluate to a true or false value. - # + # * :strict - Specifies whether validation should be strict. + # See ActiveModel::Validation#validates! for more information + # If you pass any additional configuration options, they will be passed # to the class and available as options: # @@ -140,4 +142,4 @@ module ActiveModel end end end -end \ No newline at end of file +end -- cgit v1.2.3 From c317419359d9d868c4e8c12a2ba2e2f541eef3d6 Mon Sep 17 00:00:00 2001 From: Evgeniy Dolzhenko Date: Tue, 11 Oct 2011 14:13:08 +0100 Subject: Use .add instead of << to add errors --- activemodel/lib/active_model/validations/with.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activemodel/lib/active_model/validations/with.rb') diff --git a/activemodel/lib/active_model/validations/with.rb b/activemodel/lib/active_model/validations/with.rb index 83aae206a6..93a340eb39 100644 --- a/activemodel/lib/active_model/validations/with.rb +++ b/activemodel/lib/active_model/validations/with.rb @@ -32,7 +32,7 @@ module ActiveModel # class MyValidator < ActiveModel::Validator # def validate(record) # if some_complex_logic - # record.errors[:base] << "This record is invalid" + # record.errors.add :base, "This record is invalid" # end # end # -- cgit v1.2.3 From 448df2d100feccf1d5df9db2b02b732a775d8406 Mon Sep 17 00:00:00 2001 From: Alexey Vakhov Date: Sun, 27 Nov 2011 10:23:40 +0400 Subject: Cosmetic fixes in AM validatations docs --- activemodel/lib/active_model/validations/with.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activemodel/lib/active_model/validations/with.rb') diff --git a/activemodel/lib/active_model/validations/with.rb b/activemodel/lib/active_model/validations/with.rb index 93a340eb39..72b8562b93 100644 --- a/activemodel/lib/active_model/validations/with.rb +++ b/activemodel/lib/active_model/validations/with.rb @@ -56,7 +56,7 @@ module ActiveModel # if the validation should occur (e.g. :if => :allow_validation, # or :if => Proc.new { |user| user.signup_step > 2 }). # The method, proc or string should return or evaluate to a true or false value. - # * unless - Specifies a method, proc or string to call to + # * :unless - Specifies a method, proc or string to call to # determine if the validation should not occur # (e.g. :unless => :skip_validation, or # :unless => Proc.new { |user| user.signup_step <= 2 }). -- cgit v1.2.3