aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/validator.rb
Commit message (Collapse)AuthorAgeFilesLines
* Module#{attr,attr_accessor,attr_reader,attr_writer} become public since Ruby 2.5Ryuta Kamizono2018-12-211-1/+1
| | | | https://bugs.ruby-lang.org/issues/14132
* Use frozen string literal in activemodel/Kir Shatrov2017-07-161-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Fix broken RDoc formattingT.J. Schuck2017-05-261-1/+1
| | | | [ci skip]
* fix ActiveModel::Validator#kind code examples [ci skip]stve2017-05-021-2/+2
|
* remove uniqueness validators from ActiveModel examplesstve2017-05-021-2/+2
|
* Fix typoScott González2017-01-101-2/+2
|
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+0
|
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-3/+3
|
* applies new string literal convention in activemodel/libXavier Noria2016-08-061-1/+1
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Chomp: prefer String#chomp where we can for a clarity boostlvl0nax2016-04-291-1/+1
| | | | | | Closes #24766, #24767 Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
* Revert changes to validations from PR #18612eileencodes2016-02-231-11/+0
| | | | | | | | | | | | | | | | | | | | In order to fix issue #17621 we added a check to validations that determined if a record should be validated. Based on the existing tests and behavior we wanted we determined the best way to do that was by checking if `!record.peristed? || record.changed? || record.marked_for_destruction?` This change didn't make it into a release until now. When #23790 was opened we realized that `valid?` and `invalid?` were broken and did not work on persisted records because of the `!record.persisted?`. While there is still a bug that #17621 brought up, this change was too drastic and should not be a RC blocker. I will work on fixing this so that we don't break `valid?` but also aren't validating parent records through child records if that parent record is validate false. This change removes the code changes to validate and the corresponding tests. It adds tests for two of the bugs found since Rails 5 beta2 release. Fixes #17621
* Always validate record if validating a virtual attributeeileencodes2016-02-201-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #23645 When you're using an `attr_accessor` for a record instead of an attribute in the database there's no way for the record to know if it has `changed?` unless you tell it `attribute_will_change!("attribute")`. The change made in 27aa4dd updated validations to check if a record was `changed?` or `marked_for_destruction?` or not `persisted?`. It did not take into account virtual attributes that do not affect the model's dirty status. The only way to fix this is to always validate the record if the attribute does not belong to the set of attributes the record expects (in `record.attributes`) because virtual attributes will not be in that hash. I think we should consider deprecating this particular behavior in the future and requiring that the user mark the record dirty by noting that the virtual attribute will change. Unfortunately this isn't easy because we have no way of knowing that you did the "right thing" in your application by marking it dirty and will get the deprecation warning even if you are doing the correct thing. For now this restores expected behavior when using a virtual attribute by always validating the record, as well as adds tests for this case. I was going to add the `!record.attributes.include?(attribute)` to the `should_validate?` method but `uniqueness` cannot validate a virtual attribute with nothing to hold on to the attribute. Because of this `should_validate?` was about to become a very messy method so I decided to split them up so we can handle it specifically for each case.
* Change the deprecation messages to show the preferred way to work withRafael Mendonça França2015-02-201-1/+1
| | | | ActiveModel::Errors
* use `messages` instead of deprecated `ActiveModel::Errors#[]=` method [ci skip]yuuji.yaginuma2015-02-201-1/+1
|
* Fix validations on child record when record parent has validate: falseeileencodes2015-02-011-0/+4
| | | | | | | | | | | | | | Fixes #17621. This 5 year old (or older) issue causes validations to fire when a parent record has `validate: false` option and a child record is saved. It's not the responsibility of the model to validate an associated object unless the object was created or modified by the parent. Clean up tests related to validations `assert_nothing_raised` is not benefiting us in these tests Corrected spelling of "respects" It's better to use `assert_not_operator` over `assert !r.valid`
* Use Active Model, not ActiveModel in plain Englishclaudiob2015-01-021-1/+1
| | | | | | | Also prevents the word "Model" from linking to the documentation of ActiveModel::Model because that's not intended. [ci skip]
* Fix example code of `EachValidator` [ci skip]Chun-wei Kuo2014-07-281-1/+1
| | | | | We have to specify the `:title` option to really use the `TitleValidator` defined above.
* remove depricated Validatior#setupKuldeep Aggarwal2014-06-101-16/+0
|
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2013-12-201-1/+1
|\
| * Typos. return -> returns. [ci skip]Lauro Caetano2013-12-031-1/+1
| |
* | Fix typo [ci skip]Rafael Mendonça França2013-12-131-1/+1
| |
* | typos rectified lifecycle => life cycleAayush khandelwal2013-12-121-1/+1
|/
* deprecate Validator#setup (to get rid of a respond_to call). validators do ↵Nick Sutterer2013-05-231-9/+23
| | | | their setup in their constructor now.
* Clarify ActiveModel::Validator initialization in docs.Henrik Nyh2013-02-091-0/+3
| | | As discussed with @josevalim on Ruby Rogues Parley.
* Set default value to ActiveModel::Validator initializer attributeIrio Irineu Musskopf Junior2013-01-091-1/+1
| | | | Makes it easier to test its objects.
* Remove ActiveModel::Errors#add_on_present method.Rafael Mendonça França2012-12-211-1/+1
| | | | | | | | We don't need to define a new method in ActiveMode::Errors for each validatior. See https://github.com/rails/rails/commit/d72a07f1d1478db9daed847eadb35bfd840674f6#commitcomment-2325333
* Replace comments' non-breaking spaces with spacesclaudiob2012-12-041-2/+2
| | | | | | | | | | Sometimes, on Mac OS X, programmers accidentally press Option+Space rather than just Space and don’t see the difference. The problem is that Option+Space writes a non-breaking space (0XA0) rather than a normal space (0x20). This commit removes all the non-breaking spaces inadvertently introduced in the comments of the code.
* Raise ArgumentError when no attribute is given to AMo::EachValidatorCarlos Antonio da Silva2012-11-041-1/+1
| | | | ArgumentError is better suited than RuntimeError for this.
* convert comments to 1.9 hash syntaxAvnerCohen2012-10-221-1/+1
|
* minor edits in AM documentation [ci skip]Francesco Rodriguez2012-10-211-1/+1
|
* removes usage of Object#in? from the code base (the method remains defined ↵Xavier Noria2012-08-061-1/+1
| | | | | | | | | | | | | | | | | | | by Active Support) Selecting which key extensions to include in active_support/rails made apparent the systematic usage of Object#in? in the code base. After some discussion in https://github.com/rails/rails/commit/5ea6b0df9a36d033f21b52049426257a4637028d we decided to remove it and use plain Ruby, which seems enough for this particular idiom. In this commit the refactor has been made case by case. Sometimes include? is the natural alternative, others a simple || is the way you actually spell the condition in your head, others a case statement seems more appropriate. I have chosen the one I liked the most in each case.
* Merge branch 'master' of github.com:lifo/docrailsVijay Dev2012-08-041-11/+11
|\ | | | | | | | | | | Conflicts: activemodel/lib/active_model/secure_password.rb activerecord/lib/active_record/associations/collection_proxy.rb
| * update ActiveModel::Validations docs [ci skip]Francesco Rodriguez2012-07-291-1/+1
| |
| * update ActiveModel::Validator docs [ci skip]Francesco Rodriguez2012-07-291-10/+10
| |
* | load active_support/core_ext/object/inclusion in active_support/railsXavier Noria2012-08-021-1/+0
| |
* | load active_support/core_ext/object/blank in active_support/railsXavier Noria2012-08-021-1/+0
|/
* add :nodoc: to internal implementations of AM::Validator [ci skip]Francesco Rodriguez2012-07-061-2/+2
|
* Remove Array.wrap call in ActiveModelRafael Mendonça França2012-01-061-2/+1
|
* correct documentation on initialize method to accept a single parameterbradrobertson2011-10-261-1/+1
|
* Use .add instead of << to add errorsEvgeniy Dolzhenko2011-10-111-3/+3
|
* Remove `#among?` from Active SupportPrem Sichanugrist2011-04-131-1/+1
| | | | | | After a long list of discussion about the performance problem from using varargs and the reason that we can't find a great pair for it, it would be best to remove support for it for now. It will come back if we can find a good pair for it. For now, Bon Voyage, `#among?`.
* Change Object#either? to Object#among? -- thanks to @jamesarosen for the ↵David Heinemeier Hansson2011-04-121-1/+1
| | | | suggestion!
* Using Object#in? and Object#either? in various placesPrem Sichanugrist2011-04-111-1/+2
| | | | There're a lot of places in Rails source code which make a lot of sense to switching to Object#in? or Object#either? instead of using [].include?.
* Add additional text to NotImplementedErrors [#6328 state:resolved]Mike Gehard2011-03-121-2/+2
| | | | Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* formatting changesVijay Dev2011-03-071-12/+11
|
* Remove Example headers. Code just flows with the text. 6ce844a3Paco Guzman2011-03-061-3/+1
|
* Tiny fixes to rdocAlexey Mahotkin2010-09-161-2/+2
|