From 26353b993b3bfb52d6c4adb92b6aa08d9712fd06 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Thu, 26 Apr 2012 10:09:12 +0200 Subject: Add documentation for validate options --- activemodel/lib/active_model/validations.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'activemodel/lib/active_model') diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index ebb0dbb1ca..b5e9d7514a 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -128,6 +128,19 @@ module ActiveModel # end # end # + # Options: + # * :on - Specifies the context where this validation is active + # (e.g. :on => :create or :on => :custom_validation_context) + # * :allow_nil - Skip validation if attribute is +nil+. + # * :allow_blank - Skip validation if attribute is blank. + # * :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. + # * :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. def validate(*args, &block) options = args.extract_options! if options.key?(:on) -- cgit v1.2.3