aboutsummaryrefslogtreecommitdiffstats
path: root/railties/doc/guides/source/activerecord_validations_callbacks.txt
diff options
context:
space:
mode:
authorCassioMarques <cassiommc@gmail.com>2008-11-09 23:02:01 -0200
committerCassioMarques <cassiommc@gmail.com>2008-11-09 23:02:01 -0200
commit0419efc1b9dc06c29d9b7b83ef84a6cf0fc500c2 (patch)
treeb5fd7a1fde281a2ee50626b2ac3571ac0d63c549 /railties/doc/guides/source/activerecord_validations_callbacks.txt
parent561900fb6715ffd11a1cca672c6c87be6ddda0ae (diff)
downloadrails-0419efc1b9dc06c29d9b7b83ef84a6cf0fc500c2.tar.gz
rails-0419efc1b9dc06c29d9b7b83ef84a6cf0fc500c2.tar.bz2
rails-0419efc1b9dc06c29d9b7b83ef84a6cf0fc500c2.zip
Added documentation for validates_format_of
Diffstat (limited to 'railties/doc/guides/source/activerecord_validations_callbacks.txt')
-rw-r--r--railties/doc/guides/source/activerecord_validations_callbacks.txt13
1 files changed, 12 insertions, 1 deletions
diff --git a/railties/doc/guides/source/activerecord_validations_callbacks.txt b/railties/doc/guides/source/activerecord_validations_callbacks.txt
index 2e121e959b..f61bea9d3d 100644
--- a/railties/doc/guides/source/activerecord_validations_callbacks.txt
+++ b/railties/doc/guides/source/activerecord_validations_callbacks.txt
@@ -159,10 +159,21 @@ end
The +validates_exclusion_of+ helper has an option +:in+ that receives the set of values that will not be accepted for the validated attributes. The +:in+ option has an alias called +:within+ that you can use for the same purpose, if you'd like to. In the previous example we used the +:message+ option to show how we can personalize it with the current attribute's value, through the +%s+ format mask.
-The default error message for +validates_exclusion_of+ is "_is not included in the list_"
+The default error message for +validates_exclusion_of+ is "_is not included in the list_".
=== The +validates_format_of+ helper
+This helper validates the attributes's values by testing if they match a given pattern. This pattern must be specified using a Ruby regular expression, which must be passed through the +:with+ option.
+
+[source, ruby]
+------------------------------------------------------------------
+class Product < ActiveRecord::Base
+ validates_format_of :description, :with => /^[a-zA-Z]+$/, :message => "Only letters allowed"
+end
+------------------------------------------------------------------
+
+The default error message for +validates_format_of+ is "_is invalid_".
+
=== The +validates_inclusion_of+ helper
=== The +validates_length_of+ helper