Created
August 16, 2010 08:23
-
-
Save matsuda/526623 to your computer and use it in GitHub Desktop.
「英大文字」「英小文字」「数字」「記号」のうち、単一の1種類のみで構成されることなく、2種類以上が使われていること
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 「英大文字」「英小文字」「数字」「記号」のうち、単一の1種類のみで構成されることなく、2種類以上が使われていること | |
# http://e-words.jp/p/r-ascii.html | |
class User | |
PASSWORD_FORMAT = %r{^ | |
(?![0-9])[\x20-\x7e]*?[0-9][\x20-\x7e]*?| | |
(?![a-z])[\x20-\x7e]*?[a-z][\x20-\x7e]*?| | |
(?![A-Z])[\x20-\x7e]*?[A-Z][\x20-\x7e]*?| | |
(?![!-\/:-@\[-`\{-~])[\x20-\x7e]*?[!-\/:-@\[-`\{-~][\x20-\x7e]*? | |
$}x | |
validates_format_of :password, :with => PASSWORD_FORMAT, :message => 'は英大文字・英小文字・数字・記号のうち2種類以上を使ってください。', :allow_nil => true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment