直播链接的正则判断

dev_video
cxt 5 years ago
parent 66d28a896a
commit 4c634b85ed

@ -4,4 +4,5 @@ module CustomRegexp
LASTNAME = /\A[a-zA-Z0-9\u4e00-\u9fa5]+\z/
NICKNAME = /\A[\u4e00-\u9fa5_a-zA-Z0-9]+\z/
PASSWORD = /\A[a-z_A-Z0-9\-\.!@#\$%\\\^&\*\)\(\+=\{\}\[\]\/",'_<>~\·`\?:;|]{8,16}\z/
URL = /\Ahttps?:\/\/[-A-Za-z0-9+&@#\/%?=~_|!:,.;]+[-A-Za-z0-9+&@#\/%=~_|]\z/
end

@ -4,7 +4,7 @@ class LiveLink < ApplicationRecord
has_many :tidings, as: :container, dependent: :destroy
validates :url, presence: true
validates :url, presence: true, format: { with: CustomRegexp::URL, message: "必须为网址超链接" }
validates :description, length: { maximum: 100, too_long: "不能超过100个字符" }
def op_auth?

Loading…
Cancel
Save