mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 03:21:12 +08:00
FEATURE: allow for a localized error when a regex fails in site settings
FEATURE: apply string validation to list site settings (so we get regex)
This commit is contained in:
@ -2,6 +2,7 @@ class StringSettingValidator
|
||||
def initialize(opts={})
|
||||
@opts = opts
|
||||
@regex = Regexp.new(opts[:regex]) if opts[:regex]
|
||||
@regex_error = opts[:regex_error] || 'site_settings.errors.regex_mismatch'
|
||||
end
|
||||
|
||||
def valid_value?(val)
|
||||
@ -22,7 +23,7 @@ class StringSettingValidator
|
||||
|
||||
def error_message
|
||||
if @regex_fail
|
||||
I18n.t('site_settings.errors.regex_mismatch')
|
||||
I18n.t(@regex_error)
|
||||
elsif @length_fail
|
||||
if @opts[:min] && @opts[:max]
|
||||
I18n.t('site_settings.errors.invalid_string_min_max', {min: @opts[:min], max: @opts[:max]})
|
||||
|
Reference in New Issue
Block a user