From 0557273f38fcbdaa661715dbb2c2d8ffaf264e36 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sun, 29 Jul 2012 19:57:48 -0500 Subject: update ActiveModel::Valdations#validates_with docs [ci skip] --- activemodel/lib/active_model/validations/with.rb | 34 +++++++++++++----------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'activemodel/lib/active_model') diff --git a/activemodel/lib/active_model/validations/with.rb b/activemodel/lib/active_model/validations/with.rb index 3c516f8b22..869591cd9e 100644 --- a/activemodel/lib/active_model/validations/with.rb +++ b/activemodel/lib/active_model/validations/with.rb @@ -34,7 +34,7 @@ module ActiveModel # class MyValidator < ActiveModel::Validator # def validate(record) # if some_complex_logic - # record.errors.add :base, "This record is invalid" + # record.errors.add :base, 'This record is invalid' # end # end # @@ -48,30 +48,32 @@ module ActiveModel # # class Person # include ActiveModel::Validations - # validates_with MyValidator, MyOtherValidator, :on => :create + # validates_with MyValidator, MyOtherValidator, on: :create # end # # Configuration options: # * :on - Specifies when this validation is active - # (:create or :update + # (:create or :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 }). - # The method, proc or string should return or evaluate to a true or false value. + # 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 # determine if the validation should not occur - # (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. + # (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: + # to the class and available as +options+: # # class Person # include ActiveModel::Validations - # validates_with MyValidator, :my_custom_key => "my custom value" + # validates_with MyValidator, my_custom_key: 'my custom value' # end # # class MyValidator < ActiveModel::Validator @@ -119,17 +121,17 @@ module ActiveModel # class Person # include ActiveModel::Validations # - # validate :instance_validations, :on => :create + # validate :instance_validations, on: :create # # def instance_validations # validates_with MyValidator, MyOtherValidator # end # end # - # Standard configuration options (:on, :if and :unless), which are - # available on the class version of +validates_with+, should instead be - # placed on the +validates+ method as these are applied and tested - # in the callback. + # Standard configuration options (:on, :if and + # :unless), which are available on the class version of + # +validates_with+, should instead be placed on the +validates+ method + # as these are applied and tested in the callback. # # If you pass any additional configuration options, they will be passed # to the class and available as +options+, please refer to the -- cgit v1.2.3