mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-04 21:01:27 -05:00
11 lines
346 B
Ruby
11 lines
346 B
Ruby
class UploadUrlValidator < ActiveModel::EachValidator
|
|
def validate_each(record, attribute, value)
|
|
if value.present?
|
|
uri = URI.parse(value) rescue nil
|
|
|
|
unless uri && Discourse.store.has_been_uploaded?(value)
|
|
record.errors[attribute] << (options[:message] || I18n.t('errors.messages.invalid'))
|
|
end
|
|
end
|
|
end
|
|
end
|