Commit Graph

63 Commits

Author SHA1 Message Date
Aditya Sanghi
bf5cf5db86 :if should not fire on validations when not in context with :on 2011-04-29 02:54:37 +05:30
Vijay Dev
f99db5a6a8 formatting changes 2011-03-07 23:56:16 +05:30
Xavier Noria
b481574a33 copy-edits 8d96b89 2011-02-21 11:37:08 +01:00
Peer Allan
8d96b89110 Clarification of ActiveRecord ActiveModel validation documentation 2011-02-18 20:51:56 -06:00
Santiago Pastorino
933adce8f4 Use map + flatten here 2011-02-07 19:15:06 -02:00
Carl Lerche
cf9324e590 Find all validators for multiple attributes 2011-02-05 20:27:02 -08:00
John Firebaugh
57bc25c5f8 Use run_callbacks; the generated _run_<name>_callbacks method is not a public interface.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2011-01-31 19:45:53 -02:00
Santiago Pastorino
5fb42ac478 Tests and docs which explain the use of validate with a block and without arguments 2010-12-19 18:50:18 -02:00
fastred
4ea9a8d9ad Fix syntax error in ActiveModel::Validations .validate example 2010-10-01 18:32:46 +02:00
Mikel Lindsaar
bca9b84a4a Fixing documentation to reflect deprecated add_to_base 2010-09-12 14:19:38 +10:00
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
Greg Campbell
90a7915ab2 Add missing ActiveModel::Validations require
[#5311 state: resolved]

ActiveModel::Validations uses Hash#except, but does not require it from
ActiveSupport.  (This wasn't showing up in the tests, because it was
required in the helper, and was also required in
ActiveModel::Serialization).

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-08-12 13:11:48 -03:00
José Valim
84081fcc54 Freeze options so we raise an error when people modify it in place. 2010-08-03 15:36:23 +02:00
Xavier Noria
755af49755 edit pass to apply API guideline wrt the use of "# =>" in example code 2010-07-30 02:30:04 +02:00
Xavier Noria
207fa59675 Merge remote branch 'rails/master'
Conflicts:
	actionpack/lib/abstract_controller/base.rb
2010-06-20 23:13:19 +02:00
José Valim
0247995d05 ActiveModel::Validations::Callbacks should not be required by default. 2010-06-19 18:20:02 +02:00
Neeraj Singh
51739d3228 moving before_validation and after_validation functionality from ActiveRecord to ActiveModel
[#4653 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-06-19 17:59:52 +02:00
Evgeniy Dolzhenko
ef404c771d Fix a bunch of minor spelling mistakes 2010-06-15 12:04:22 +04:00
Rizwan Reza
7d7d54fa1f Revised the rest of the files from ActiveModel. 2010-06-14 13:56:51 +04:30
Evgeniy Dolzhenko
ccf9577aee Fix a bunch of minor spelling mistakes 2010-06-11 14:15:34 +04:00
José Valim
b67ec8ba20 class_attribute is not a direct replacement of class_inheritable_*.
If you are setting a hash or an array in class_attribute or you need
to freeze it, to ensure people won't modify it in place or you need
to dup it on inheritance.
2010-06-10 19:39:09 +02:00
Neeraj Singh
e11bb95d56 Validators should at model level and not at AR:Base level [Closes #4804]
[#4804 state:resolved]

Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
2010-06-10 11:50:42 -04:00
Josh Kalderimis
92160219a8 minor changes to instance level validations implementation based on feedback from José Valim 2010-05-13 13:57:37 -07:00
Josh Kalderimis
9131a88bb8 validation macros can now be used within an instance 2010-05-13 13:57:37 -07:00
Josh Kalderimis
82485068f8 updated AMo validations to use a context for valid? and invalid?, removing the dependency on AR 2010-05-08 23:51:28 +03: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
Jeremy Kemper
a98db7c6ef Use Array.wrap uniformly 2010-03-27 11:50:11 -07:00
José Valim
4c7c406155 Remove reference to unexistent methods and fix typo. 2010-03-26 01:12:24 +01:00
Jeremy Kemper
2ba6049506 Accept array of attributes as arg also, like 2.3 2010-02-25 13:07:48 -08:00
Prem Sichanugrist
8f97e9d19a Add validators reflection so you can do 'Person.validators' and 'Person.validators_on(:name)'.
Signed-off-by: José Valim <jose.valim@gmail.com>
2010-02-21 12:37:46 +01:00
Mikel Lindsaar
a07d0f8786 Full update on ActiveModel documentation 2010-02-01 10:08:20 +11:00
José Valim
47a5fd4c4b Allow :if, :unless, :on, :allow_nil and :allow_blank as shared options in validates. 2010-01-07 19:23:59 +01: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
Jeremy Kemper
632df063a3 Merge commit 'josevalim/validations' 2009-12-28 11:13:35 -08:00
José Valim
279067639f validates_each uses a BlockValidator. 2009-12-23 01:38:15 +01:00
Joshua Peek
f737c2d69b All AMo modules are safe to defer 2009-12-22 17:39:41 -06:00
José Valim
e714b499cc Move validator, human_name and human_attribute_name to ActiveModel, remove deprecated error messages and add i18n_scope and lookup_ancestors.
Signed-off-by: Carl Lerche <carllerche@mac.com>
2009-10-20 17:52:32 -07:00
Joshua Peek
21e7b84621 Callbacks, DeprecatedCallbacks = NewCallbacks, Callbacks 2009-10-12 22:15:43 -05:00
José Valim
2ea1d684d9 Refactor new callbacks and AR implementation.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-09-08 10:26:39 -05:00
José Valim
4f37b97033 Changed ActiveRecord to use new callbacks and speed up observers by only notifying events that are actually being consumed.
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-09-08 10:26:39 -05:00
Pratik Naik
5ce3831faf Use send instead of instance_eval 2009-08-06 00:11:28 +01:00
James Hill
cfd421daa2 Allow validations to use values from custom readers [#2936 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
2009-08-05 11:45:01 -05:00
Yehuda Katz
1a2946a6d9 Add some missing dependencies 2009-07-15 14:16:30 -07:00
Joshua Peek
d5d59230f4 Simplify AMo validation attribute reader 2009-06-17 21:27:54 -05:00
Joshua Peek
28f36279cd Properly require ActiveModel validation dependencies 2009-06-08 20:32:08 -05:00
Joshua Peek
e7d6f48ea9 Use AS::Concern in ActiveModel 2009-05-30 09:35:24 -05:00
Pratik Naik
d758d996d1 Deprecate Model#validate/validate_on_create/validate_on_update. Use Model.validate :method and likewise 2009-03-21 19:07:15 +00:00
Pratik Naik
2bc4189faf Get rid of active_model/core and active_model/callbacks 2009-03-21 01:32:59 +00:00
Pratik Naik
379e468034 Remove DEFAULT_VALIDATION_OPTIONS from validations 2009-03-21 01:14:58 +00:00
Pratik Naik
22ad30ed60 Move validate_on_create and validate_on_update from ActiveModel to ActiveRecord 2009-03-21 01:11:38 +00:00