mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FEATURE: custom colors for default letter avatars (#7167)
This commit is contained in:
14
lib/validators/color_list_validator.rb
Normal file
14
lib/validators/color_list_validator.rb
Normal file
@ -0,0 +1,14 @@
|
||||
class ColorListValidator
|
||||
def initialize(opts = {})
|
||||
@opts = opts
|
||||
end
|
||||
|
||||
def valid_value?(value)
|
||||
hex_regex = /\A\h{6}\z/
|
||||
value.split("|").all? { |c| c =~ hex_regex }
|
||||
end
|
||||
|
||||
def error_message
|
||||
I18n.t('site_settings.errors.invalid_hex_value')
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user