aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/CHANGELOG.md
diff options
context:
space:
mode:
authorVince Puzzella <vincepuz@gmail.com>2014-01-18 11:34:38 -0500
committerVince Puzzella <vincepuz@gmail.com>2014-01-27 03:26:27 -0500
commit8855163bdbce23fa539be2c1ef2a49f1aabc6458 (patch)
tree3429079077006499431452eaadc42737d28f6997 /activemodel/CHANGELOG.md
parent5540dfccd88c809c2922f21f4c1558465bce26dd (diff)
downloadrails-8855163bdbce23fa539be2c1ef2a49f1aabc6458.tar.gz
rails-8855163bdbce23fa539be2c1ef2a49f1aabc6458.tar.bz2
rails-8855163bdbce23fa539be2c1ef2a49f1aabc6458.zip
Ability to specify multiple contexts when defining a validation.
Example: validates_presence_of :name, on: [:update, :custom_validation_context]
Diffstat (limited to 'activemodel/CHANGELOG.md')
-rw-r--r--activemodel/CHANGELOG.md20
1 files changed, 20 insertions, 0 deletions
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md
index 09fdd84844..0148066bac 100644
--- a/activemodel/CHANGELOG.md
+++ b/activemodel/CHANGELOG.md
@@ -1,3 +1,23 @@
+* Ability to specify multiple contexts when defining a validation.
+
+ Example:
+
+ class Person
+ include ActiveModel::Validations
+
+ attr_reader :name
+ validates_presence_of :name, on: [:verify, :approve]
+ end
+
+ person = Person.new
+ person.valid? # => true
+ person.valid?(:verify) # => false
+ person.errors.full_messages_for(:name) # => ["Name can't be blank"]
+ person.valid?(:approve) # => false
+ person.errors.full_messages_for(:name) # => ["Name can't be blank"]
+
+ *Vince Puzzella*
+
* `attribute_changed?` now accepts parameters which check the old and new value of the attribute
`model.name_changed?(from: "Pete", to: "Ringo")`