mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
3650ca983c
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"] }
41 lines
1.2 KiB
Markdown
41 lines
1.2 KiB
Markdown
* Add method `#merge!` for `ActiveModel::Errors`.
|
|
|
|
*Jahfer Husain*
|
|
|
|
* Fix regression in numericality validator when comparing Decimal and Float input
|
|
values with more scale than the schema.
|
|
|
|
*Bradley Priest*
|
|
|
|
* Fix methods `#keys`, `#values` in `ActiveModel::Errors`.
|
|
|
|
Change `#keys` to only return the keys that don't have empty messages.
|
|
|
|
Change `#values` to only return the not empty values.
|
|
|
|
Example:
|
|
|
|
# Before
|
|
person = Person.new
|
|
person.errors.keys # => []
|
|
person.errors.values # => []
|
|
person.errors.messages # => {}
|
|
person.errors[:name] # => []
|
|
person.errors.messages # => {:name => []}
|
|
person.errors.keys # => [:name]
|
|
person.errors.values # => [[]]
|
|
|
|
# After
|
|
person = Person.new
|
|
person.errors.keys # => []
|
|
person.errors.values # => []
|
|
person.errors.messages # => {}
|
|
person.errors[:name] # => []
|
|
person.errors.messages # => {:name => []}
|
|
person.errors.keys # => []
|
|
person.errors.values # => []
|
|
|
|
*bogdanvlviv*
|
|
|
|
|
|
Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/activemodel/CHANGELOG.md) for previous changes.
|