diff options
author | Bogdan Gusiev <agresso@gmail.com> | 2012-08-06 13:45:27 +0300 |
---|---|---|
committer | Bogdan Gusiev <agresso@gmail.com> | 2012-08-06 13:45:27 +0300 |
commit | 2e4f7986b8ec90d7b41c385388be21b8cee79b9c (patch) | |
tree | d7dd64e1c97b9dcf1c263ebd2bd408b7fd7c9208 /activemodel/lib/active_model/validations | |
parent | 5edfc463484827df364a1e589677d5c84dfac282 (diff) | |
download | rails-2e4f7986b8ec90d7b41c385388be21b8cee79b9c.tar.gz rails-2e4f7986b8ec90d7b41c385388be21b8cee79b9c.tar.bz2 rails-2e4f7986b8ec90d7b41c385388be21b8cee79b9c.zip |
AM::Validation#validates: ability to pass custom exception to `:strict` option
Diffstat (limited to 'activemodel/lib/active_model/validations')
-rw-r--r-- | activemodel/lib/active_model/validations/validates.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/validations/validates.rb b/activemodel/lib/active_model/validations/validates.rb index 5892ad29d1..eb6e604851 100644 --- a/activemodel/lib/active_model/validations/validates.rb +++ b/activemodel/lib/active_model/validations/validates.rb @@ -84,12 +84,15 @@ module ActiveModel # or <tt>unless: Proc.new { |user| user.signup_step <= 2 }</tt>). The # method, proc or string should return or evaluate to a +true+ or # +false+ value. - # * <tt>:strict</tt> - Specifies whether validation should be strict. - # See <tt>ActiveModel::Validation#validates!</tt> for more information. + # * <tt>:strict</tt> - if the <tt>:strict</tt> option is set to true + # will raise ActiveModel::StrictValidationFailed instead of adding the error. + # <tt>:strict</tt> option can also be set to any other exception. # # Example: # # validates :password, presence: true, confirmation: true, if: :password_required? + # validates :token, uniqueness: true, strict: TokenGenerationException + # # # Finally, the options +:if+, +:unless+, +:on+, +:allow_blank+, +:allow_nil+ # and +:strict+ can be given to one specific validator, as a hash: |