mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FEATURE: add flair to avatars using new settings in the groups admin UI
This commit is contained in:
11
lib/validators/url_validator.rb
Normal file
11
lib/validators/url_validator.rb
Normal file
@ -0,0 +1,11 @@
|
||||
class UrlValidator < ActiveModel::EachValidator
|
||||
def validate_each(record, attribute, value)
|
||||
if value.present?
|
||||
uri = URI.parse(value) rescue nil
|
||||
|
||||
unless uri
|
||||
record.errors[attribute] << (options[:message] || I18n.t('errors.messages.invalid'))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user