身份证正则匹配

dev_local_2
daiao 6 years ago
parent 68a2a38895
commit 40df91eb5d

@ -657,7 +657,7 @@ class GamesController < ApplicationController
# 高性能取上一关、下一关
prev_game = @game.prev_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position)
next_game = @game.next_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position) if had_passed
next_game = @game.next_game(@shixun.id, @game.myshixun_id, game_challenge.position) if had_passed
next_game.update_column(:status, 0) if next_game.present? && next_game.status == 3
# 高性能取上一关、下一关
@ -671,7 +671,7 @@ class GamesController < ApplicationController
choose_correct_num: choose_correct_num,
test_sets: test_sets,
prev_game: prev_game,
next_game: next_game}
next_game: next_game&.identifier}
rescue Exception => e
uid_logger("choose build failed #{e.message}")
@result = [status: -1, contents: "#{e.message}"]

@ -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_REGE
# validates :nickname, presence: true, length: { maximum: 10 }
# validates :lastname, presence: true

Loading…
Cancel
Save