Commit Graph

158 Commits

Author SHA1 Message Date
bogdanvlviv 7308991630
Execute `ConfirmationValidator` validation when `_confirmation`'s value is `false` 2017-11-05 19:24:49 +00:00
Matt Rohrer b8b089ef11
Allow passing a Proc or Symbol as an argument to length validator values
This brings the Length validator in line with the Numericality
validator, which currently supports Proc & Symbol arguments
2017-10-26 10:01:06 +02:00
Jahfer Husain 3650ca983c Add ActiveModel::Errors#merge!
ActiveModel::Errors#merge! allows ActiveModel::Errors to append errors from
a separate ActiveModel::Errors instance onto their own.

Example:

    person = Person.new
    person.errors.add(:name, :blank)

    errors = ActiveModel::Errors.new(Person.new)
    errors.add(:name, :invalid)

    person.errors.merge!(errors)
    puts person.errors.messages
    # => { name: ["can't be blank", "is invalid"] }
2017-07-07 14:32:59 -04:00
Ryuta Kamizono 9fdebb17ff ✂️
[ci skip]
2017-06-28 22:21:03 +09:00
Bradley Priest d83b8e6510 Fix regression in Numericality validator where extra decimal places on
a user input for a decimal column were ignored by numerically validations
2017-05-27 21:58:35 +08:00
Ryuta Kamizono 89389428b5 Cleanup CHANGELOGs [ci skip]
* Remove trailing spaces.
* Add backticks around method and command.
* Fix indentation.
2017-04-30 02:41:44 +09:00
Jon Moss a02fb802e9 Remove CHANGELOG.md entry that appears in 5-1-stable
This CHANGELOG.md is a continuation of the 5-1-stable one, there
shouldn't be any duplicate entries.

[ci skip]
2017-03-29 08:38:01 -04:00
bogdanvlviv 01269aede3 Fix ActiveModel::Errors #keys, #values
Before:
  person.errors.keys    # => []
  person.errors.values  # => []
  person.errors[:name]  # => []
  person.errors.keys    # => [:name]
  person.errors.values  # => [[]]

After:
  person.errors.keys   # => []
  person.errors.values # => []
  person.errors[:name] # => []
  person.errors.keys   # => []
  person.errors.values # => []

Related to #23468
2017-03-28 18:48:56 +03:00
Rafael Mendonça França 9426bd7a19
Merge pull request #28050 from namusyaka/avoid-converting-int-into-float
Avoid converting integer as a string into float
2017-03-27 18:23:56 -04:00
Matthew Draper 6c08d480f1 Start Rails 5.2 development 2017-03-22 10:11:39 +10:30
Rafael Mendonça França f4acdd83ff
Preparing for 5.1.0.beta1 release 2017-02-23 14:53:21 -05:00
namusyaka b0be7792ad
Avoid converting integer as a string into float 2017-02-18 19:04:48 +09:00
Rafael Mendonça França 3a25cdca3e
Remove deprecated behavior that halts callbacks when the return is false 2017-02-07 12:19:37 -03:00
yuuji.yaginuma 4f8d86c822 Remove `ActiveModel::TestCase` from lib
`ActiveModel::TestCase` is used only for the test of Active Model.
Also, it is a private API and can not be used in applications.
Therefore, it is not necessary to include it in lib.
2017-02-07 07:46:52 +09:00
Sean Griffin ef76f83f4c Merge pull request #26696 from iainbeeston/only-ruby-types-in-activemodel
Moved database-specific ActiveModel types into ActiveRecord
2016-12-08 13:45:47 -05:00
Kenichi Kamiya 9f566aba32 Allow indifferent access in ActiveModel::Errors
`#[]` has already applied indifferent access, but some methods does not.

  `#include?`, `#has_key?`, `#key?`, `#delete` and `#full_messages_for`.
2016-11-22 04:10:41 +09:00
Iain Beeston 994ce87bbd Moved database-specific ActiveModel types into ActiveRecord
ie. DecimalWithoutScale, Text and UnsignedInteger
2016-10-14 20:21:20 +01:00
Rafael Mendonça França 6a78e0ecd6
Removed deprecated :tokenizer in the length validator 2016-10-10 20:29:24 -03:00
Rafael Mendonça França 9de6457ab0
Removed deprecated methods in ActiveModel::Errors
`#get`, `#set`, `[]=`, `add_on_empty` and `add_on_blank`.
2016-10-10 20:22:15 -03:00
Rafael Mendonça França 8ecc5ab1d8 Start Rails 5.1 development 🎉 2016-05-10 03:46:56 -03:00
Rafael Mendonça França fbdcf5221a Preparing for 5.0.0.rc1 release 2016-05-06 16:54:40 -05:00
Prathamesh Sonpatki f7d7147ae6
Active Model: Improve CHANGELOG and documentation for `validates_acceptance_of` [ci skip]
- Improve CHANGELOG entry for #18439.
- The documentation is updated as per changes in PR #18439 to the
  `accept` option.
- The explanation about the virtual attribute is moved at the end so
  that the arity of `accept` option is explained first.
- Added a note that `message` can also be passed to `validates_acceptance_of`.
2016-05-05 16:25:47 -05:00
eileencodes f7a986012a Prep Rails 5 beta 4 2016-04-27 15:48:47 -05:00
Prathamesh Sonpatki 7bdb4b5598 Allow passing record being validated to error message generator
- Pass object to I18n helper so that when calling message proc, it will
  pass that object as argument to the proc and we can generate custom
  error messages based on current record being validated.
- Based on https://github.com/rails/rails/issues/856.

[Łukasz Bandzarewicz, Prathamesh Sonpatki]
2016-04-05 12:55:02 +05:30
eileencodes dbfa8fdfc2 Preparing for 5.0.0.beta3 release
Adds changelog headers for beta3 release
2016-02-24 11:14:40 -05:00
Sean Griffin 49f6ce63f3 Preparing for Rails 5.0.0.beta2 2016-02-01 14:37:52 -07:00
Rafael Mendonça França 53954aa476 Move CHANGELOG entry to Active Record
While the type definition is in Active Model the change of behavior will
be only user facing in Active Record so better to put the entry in its
changelog.

[ci skip]
2016-01-05 23:00:57 -02:00
Andrey Novikov 0a0ffb64d8 Take UTC offset into account when assigning string value to time attribute. 2016-01-05 18:35:04 +03:00
Genadi Samokovarov c5b6ec7b0f No more no changes entries in the CHANGELOGs
During the `5.0.0.beta1` release, the CHANGELOGs got an entry like the
following:

```
* No changes.
```

It is kinda confusing as there are indeed changes after it. Not a
biggie, just a small pass over the CHANGELOGs.

[ci skip]
2015-12-21 11:46:38 +02:00
Jon Atack d3e98c6f30 Add missing @claudiob credit to change log [skip ci] 2015-12-20 22:03:53 +01:00
eileencodes 099ddfdefd Add CHANGELOG headers for Rails 5.0.0.beta1 2015-12-18 15:58:25 -05:00
Roque Pinel e2b3ccd1aa Refactor AS::Callbacks halt config and fix the documentation
Move from `AS::Callbacks::CallbackChain.halt_and_display_warning_on_return_false`
to `AS::Callbacks.halt_and_display_warning_on_return_false` base on
[this
discussion](https://github.com/rails/rails/pull/21218#discussion_r39354580)

Fix the documentation broken by 0a120a818d
2015-10-01 13:04:20 -04:00
Semyon Pupkov aef6b79967 Fix typo in activemodel changelog 2015-09-08 23:37:17 +05:00
Dmitry Polushkin e3d99e239d Validate multiple contexts on `valid?` and `invalid?` at once.
Example:

```ruby
class Person
  include ActiveModel::Validations

  attr_reader :name, :title
  validates_presence_of :name, on: :create
  validates_presence_of :title, on: :update
end

person = Person.new
person.valid?([:create, :update])    # => true
person.errors.messages               # => {:name=>["can't be blank"], :title=>["can't be blank"]}
```
2015-09-07 22:42:50 +01:00
Rafael Mendonça França 7b9b0b531f Revert "Merge pull request #21069 from dmitry/feature/validate-multiple-contexts-at-once"
This reverts commit 51dd258843, reversing
changes made to ecb4e4b21b.

This broke Active Record tests
2015-09-07 17:16:54 -03:00
Rafael Mendonça França 51dd258843 Merge pull request #21069 from dmitry/feature/validate-multiple-contexts-at-once
Validate multiple contexts on `valid?` and `invalid?` at once
2015-09-07 16:46:18 -03:00
Rafael Mendonça França 57393957e1 Merge pull request #17351 from akshat-sharma/master
Add case_sensitive option for confirmation validation
2015-09-01 02:42:43 -03:00
Akshat Sharma 2438a1cf4e Add case_sensitive option for confirmation validation
Case :- 1. In case of email confirmation one needs case insensitive comparison
        2. In case of password confirmation one needs case sensitive comparison

[ci skip] Update Guides for case_sensitive option in confirmation validation
2015-09-01 10:42:51 +05:30
Zachary Scott f7ebdb1ac5 Remove XML Serialization from core.
This includes the following classes:

- ActiveModel::Serializers::Xml
- ActiveRecord::Serialization::XmlSerializer
2015-08-07 11:01:48 -04:00
Dmitry Polushkin 86e3b047ba Validate multiple contexts on `valid?` and `invalid?` at once.
Example:

```ruby
class Person
  include ActiveModel::Validations

  attr_reader :name, :title
  validates_presence_of :name, on: :create
  validates_presence_of :title, on: :update
end

person = Person.new
person.valid?([:create, :update])    # => true
person.errors.messages               # => {:name=>["can't be blank"], :title=>["can't be blank"]}
```
2015-07-30 10:05:29 +01:00
karanarora 0750330941 Spelling/typo/grammatical fixes [ci skip]
spelling fix [ci skip]

example to be consistent [ci skip]

grammatical fix

typo fixes [ci skip]
2015-05-23 03:01:33 +05:30
Jay Elaraj b2967999ae ensure `method_missing` called for non-existing methods passed to
`ActiveModel::Serialization#serializable_hash`
2015-04-28 21:06:30 -04:00
Yves Senn cdbf685994 pass over CHANGELOGs. [ci skip] 2015-04-22 14:44:30 +02:00
Fernando Tapia Rico f072db8e4f Add `ActiveModel::Dirty#[attr_name]_previously_changed?` and
`ActiveModel::Dirty#[attr_name]_previous_change` to improve access
to recorded changes after the model has been saved.

It makes the dirty-attributes query methods consistent before and after
saving.
2015-04-21 19:30:46 +02:00
Robin Dupret 9cc41c36f7 Fix a few typos [ci skip] 2015-04-05 15:58:43 +02:00
Sean Griffin 1c341eb7cb Deprecate the `:tokenizer` option to `validates_length_of`
As demonstrated by #19570, this option is severely limited, and
satisfies an extremely specific use case. Realistically, there's not
much reason for this option to exist. Its functionality can be trivially
replicated with a normal Ruby method. Let's deprecate this option, in
favor of the simpler solution.
2015-03-29 16:34:01 -06:00
Yves Senn e71f5dad4e some indenting and punctuation fixes. [ci skip] 2015-02-23 16:54:40 +01:00
Wojciech Wnętrzak fd38838f29 Deprecate `ActiveModel::Errors` `add_on_empty` and `add_on_blank` methods
without replacement.
2015-02-19 14:10:38 +01:00
Rafael Mendonça França 3c750c4c6c Merge pull request #18634 from morgoth/deprecate-some-errors-methods
Deprecate `ActiveModel::Errors` `get`, `set` and `[]=` methods.
2015-02-18 18:58:28 -02:00
Rafael Mendonça França 7919c29d50 Merge pull request #16381 from kakipo/validate-length-tokenizer
Allow symbol as values for `tokenizer` of `LengthValidator`
2015-02-13 12:09:36 -02:00