Commit Graph

15 Commits

Author SHA1 Message Date
Santiago Pastorino
b451de0d6d Deletes trailing whitespaces (over text files only find * -type f -exec sed 's/[ \t]*$//' -i {} \;) 2010-08-14 04:12:33 -03:00
Jeroen van Dijk
26392c4ac5 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>
2010-06-21 11:55:21 +02:00
Rizwan Reza
6907bfe1ab Minor doc changes to active_model/validations/acceptance.rb 2010-06-15 22:13:30 +04:30
José Valim
d6cbb27e7b Revert "Make ActiveModel::Errors#add_on_blank and #add_on_empty accept an options hash and make various Validators pass their (filtered) options."
Having a huge array to whitelist options is not the proper way to handle this case. This means that the ActiveModel::Errors object should know about the options given in *all* validators and break the extensibility added by the validators itself. If the intent is to whitelist options before sending them to I18n, each validator should clean its respective options instead of throwing the responsibility to the Errors object.

This reverts commit bc1c8d58ec45593acba614d1d0fecb49adef08ff.
2010-05-15 21:55:16 +02:00
Jeroen van Dijk
bc1c8d58ec 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).

Original patch by Sven Fuchs, some minor changes and has been changed to be applicable to master again

[#4057 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-05-15 11:17:58 -07:00
Josh Kalderimis
9131a88bb8 validation macros can now be used within an instance 2010-05-13 13:57:37 -07:00
Santiago Pastorino
ce48b3103a Makes validates_acceptance_of to not override database fields [#4460 state:committed]
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-04-28 23:12:03 +02:00
jamie
0a79eb7889 Add validates method as shortcut to setup validators for a given set of attributes:
class Person < ActiveRecord::Base
  include MyValidators

  validates :name, :presence => true, :uniqueness => true, :length => { :maximum => 100 }
  validates :email, :presence => true, :email => true
end

[#3058 status:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-01-07 19:23:59 +01:00
José Valim
44cd9e0e71 ActiveRecord::Validations are now built on top of Validator as well. 2009-12-23 12:14:00 +01:00
José Valim
f1085f4128 Move validations in ActiveModel to validators, however all validatity checks are still in the class method. 2009-12-23 00:36:51 +01:00
Joshua Peek
28f36279cd Properly require ActiveModel validation dependencies 2009-06-08 20:32:08 -05:00
Pratik Naik
22ad30ed60 Move validate_on_create and validate_on_update from ActiveModel to ActiveRecord 2009-03-21 01:11:38 +00:00
Pratik Naik
8828b2ca67 Move all the Active Record validations to Active Model 2009-03-19 23:28:59 +00:00
Xavier Noria
64092de257 Improve documentation coverage and markup
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
2008-05-02 14:45:23 +01:00
David Heinemeier Hansson
87535bd373 Splitting them up first
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9173 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-04-01 00:05:48 +00:00