diff options
author | Matthew Draper <matthew@trebex.net> | 2014-07-18 07:07:03 +0930 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2014-07-18 07:10:49 +0930 |
commit | e213b37fc17a363ad94b06ac6c725d9fa8799013 (patch) | |
tree | 2f6a04bd34a8a170949593483e3df52c3e59fc2c /activemodel/lib | |
parent | abd74308957b383777c6a391017d39097309fe07 (diff) | |
parent | 0950d409b041415f13d037aa4293ac31f97ed236 (diff) | |
download | rails-e213b37fc17a363ad94b06ac6c725d9fa8799013.tar.gz rails-e213b37fc17a363ad94b06ac6c725d9fa8799013.tar.bz2 rails-e213b37fc17a363ad94b06ac6c725d9fa8799013.zip |
Merge pull request #16210 from sonnym/assert_valid_keys_in_validate
Check for valid options in validate method
Diffstat (limited to 'activemodel/lib')
-rw-r--r-- | activemodel/lib/active_model/validations.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index cf97f45dba..b3d345c8ca 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -141,6 +141,11 @@ module ActiveModel # value. def validate(*args, &block) options = args.extract_options! + + if args.all? { |arg| arg.is_a?(Symbol) } + options.assert_valid_keys(%i(on if unless)) + end + if options.key?(:on) options = options.dup options[:if] = Array(options[:if]) @@ -148,6 +153,7 @@ module ActiveModel Array(options[:on]).include?(o.validation_context) } end + args << options set_callback(:validate, *args, &block) end |