diff options
Diffstat (limited to 'activemodel/lib/active_model/validations.rb')
-rw-r--r-- | activemodel/lib/active_model/validations.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index cf97f45dba..7ee033ba5f 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -39,6 +39,7 @@ module ActiveModel extend ActiveSupport::Concern included do + extend ActiveModel::Naming extend ActiveModel::Callbacks extend ActiveModel::Translation @@ -141,6 +142,11 @@ module ActiveModel # value. def validate(*args, &block) options = args.extract_options! + + if args.all? { |arg| arg.is_a?(Symbol) } + options.assert_valid_keys([:on, :if, :unless]) + end + if options.key?(:on) options = options.dup options[:if] = Array(options[:if]) @@ -148,6 +154,7 @@ module ActiveModel Array(options[:on]).include?(o.validation_context) } end + args << options set_callback(:validate, *args, &block) end |