|
|
|
@ -20,6 +20,8 @@ class User < ApplicationRecord
|
|
|
|
|
|
|
|
|
|
VALID_EMAIL_REGEX = /^[a-zA-Z0-9]+([.\-_\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/i
|
|
|
|
|
VALID_PHONE_REGEX = /^1\d{10}$/
|
|
|
|
|
# 身份证
|
|
|
|
|
VALID_NUMBER_REGEX = /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
|
|
|
|
|
|
|
|
|
|
LOGIN_LENGTH_LIMIT = 30
|
|
|
|
|
MAIL_LENGTH_LMIT = 60
|
|
|
|
@ -162,6 +164,7 @@ class User < ApplicationRecord
|
|
|
|
|
# validates_format_of :mail, with: VALID_EMAIL_REGEX, multiline: true
|
|
|
|
|
# validates_format_of :phone, with: VALID_PHONE_REGEX, multiline: true
|
|
|
|
|
validate :validate_password_length
|
|
|
|
|
validate :ID_number, with: VALID_NUMBER_REGEX
|
|
|
|
|
|
|
|
|
|
# validates :nickname, presence: true, length: { maximum: 10 }
|
|
|
|
|
# validates :lastname, presence: true
|
|
|
|
|