diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 001883fb6..dc8b44d1e 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -28,6 +28,7 @@ class Attachment < ApplicationRecord scope :no_link, -> {where(link: nil)} validates_length_of :description, maximum: 100, message: "不能超过100个字符" + validates :link, format: { with: CustomRegexp::URL, message: "必须为网址超链接" }, allow_blank: true DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)