This project is archived and is in readonly mode.

Changeset [26392c4ac57e27c63984d47c6326c13f502d5786] by Jeroen van Dijk

June 21st, 2010 @ 10:55 AM

Make ActiveModel::Errors#add_on_blank and #add_on_empty accept an options hash and make various Validators pass their (filtered) options.

This makes it possible to pass additional options through Validators to message generation. E.g. plugin authors want to add validates_presence_of :foo, :format => "some format".

Also, cleanup the :default vs :message options confusion in ActiveModel validation message generation.

Also, deprecate ActiveModel::Errors#add_on_blank(attributes, custom_message) in favor of ActiveModel::Errors#add_on_blank(attributes, options).

Also, refactoring of ActiveModel and ActiveRecord Validation tests. Test are a lot more DRY now. Better test coverage as well now.

The first four points were reapplied from an older patch of Sven Fuchs which didn't apply cleanly anymore and was not complete yet.

Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/26392c4ac57e27c63984d47c6326c1...

Committed by Jeroen van Dijk

  • M activemodel/lib/active_model/errors.rb
  • M activemodel/lib/active_model/validations/acceptance.rb
  • M activemodel/lib/active_model/validations/confirmation.rb
  • M activemodel/lib/active_model/validations/exclusion.rb
  • M activemodel/lib/active_model/validations/format.rb
  • M activemodel/lib/active_model/validations/inclusion.rb
  • M activemodel/lib/active_model/validations/length.rb
  • M activemodel/lib/active_model/validations/numericality.rb
  • M activemodel/lib/active_model/validations/presence.rb
  • M activemodel/test/cases/validations/i18n_generate_message_validation_test.rb
  • M activemodel/test/cases/validations/i18n_validation_test.rb
  • M activerecord/lib/active_record/validations/associated.rb
  • M activerecord/lib/active_record/validations/uniqueness.rb
  • M activerecord/test/cases/validations/i18n_generate_message_validation_test.rb
  • M activerecord/test/cases/validations/i18n_validation_test.rb

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>