Removed duplicated code from exemplary validations for password

This commit is contained in:
ecneladis
2014-03-06 19:40:33 +01:00
parent 38584b703d
commit 84fd9503ca
2 changed files with 2 additions and 10 deletions
+2 -3
View File
@@ -4,11 +4,10 @@ class User < ActiveRecord::Base
:confirmation => true,
:length => {:within => 6..40},
:on => :create,
:if => :password#,
=begin :format => {:with => /\A.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\@\#\$\%\^\&\+\=]).*\z/}
:if => :password
=begin
validates :password, :presence => true,
:confirmation => true,
:on => :update,
:if => :password,
:format => {:with => /\A.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\@\#\$\%\^\&\+\=]).*\z/}
=end
@@ -70,16 +70,9 @@
<li>1 special character</li>
</p>
<pre class="ruby">
# VALIDATE PASSWORD BOTH AT CREATION AND WHEN UPDATING
validates :password, :presence => true,
:confirmation => true,
:length => {:within => 6..40},
:on => :create,
:if => :password,
:format => {:with => /\A.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\@\#\$\%\^\&\+\=]).*\z/}
validates :password, :presence => true,
:confirmation => true,
:on => :update,
:if => :password,
:format => {:with => /\A.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\@\#\$\%\^\&\+\=]).*\z/}