2013-03-13 69 views

回答

4

可以驗證這樣

validates_format_of :password, :with => /^[A-Za-z0-9. ! @ # $ %^& * () _ - + = ]*\z/ 
0

我更願意把這個在我的色器件的配置文件:

首先安裝寶石/添加到您的Gemfile

gem 'devise_security_extension' 

正則表達式:1個字符A-Z,A-Z的和0-9

config.password_regex = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])/