mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 02:11:08 -06:00
d312c82474
This reverts commit 282f9948cb
.
12 lines
331 B
Ruby
12 lines
331 B
Ruby
class UploadUrlValidator < ActiveModel::EachValidator
|
|
def validate_each(record, attribute, value)
|
|
if value.present?
|
|
uri = URI.parse(value) rescue nil
|
|
|
|
unless uri && Upload.exists?(url: value)
|
|
record.errors[attribute] << (options[:message] || I18n.t('errors.messages.invalid'))
|
|
end
|
|
end
|
|
end
|
|
end
|