Removed duplicated code from exemplary validations for password
This commit is contained in:
+2
-3
@@ -4,11 +4,10 @@ class User < ActiveRecord::Base
|
|||||||
:confirmation => true,
|
:confirmation => true,
|
||||||
:length => {:within => 6..40},
|
:length => {:within => 6..40},
|
||||||
:on => :create,
|
:on => :create,
|
||||||
:if => :password#,
|
:if => :password
|
||||||
=begin :format => {:with => /\A.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\@\#\$\%\^\&\+\=]).*\z/}
|
=begin
|
||||||
validates :password, :presence => true,
|
validates :password, :presence => true,
|
||||||
:confirmation => true,
|
:confirmation => true,
|
||||||
:on => :update,
|
|
||||||
:if => :password,
|
:if => :password,
|
||||||
:format => {:with => /\A.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\@\#\$\%\^\&\+\=]).*\z/}
|
:format => {:with => /\A.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\@\#\$\%\^\&\+\=]).*\z/}
|
||||||
=end
|
=end
|
||||||
|
|||||||
@@ -70,18 +70,11 @@
|
|||||||
<li>1 special character</li>
|
<li>1 special character</li>
|
||||||
</p>
|
</p>
|
||||||
<pre class="ruby">
|
<pre class="ruby">
|
||||||
# VALIDATE PASSWORD BOTH AT CREATION AND WHEN UPDATING
|
|
||||||
validates :password, :presence => true,
|
validates :password, :presence => true,
|
||||||
:confirmation => true,
|
:confirmation => true,
|
||||||
:length => {:within => 6..40},
|
:length => {:within => 6..40},
|
||||||
:on => :create,
|
|
||||||
:if => :password,
|
:if => :password,
|
||||||
:format => {:with => /\A.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\@\#\$\%\^\&\+\=]).*\z/}
|
: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/}
|
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user