Class: AllowUserLocaleEnabledValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/validators/allow_user_locale_enabled_validator.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ AllowUserLocaleEnabledValidator

Returns a new instance of AllowUserLocaleEnabledValidator.



4
5
6
# File 'lib/validators/allow_user_locale_enabled_validator.rb', line 4

def initialize(opts = {})
  @opts = opts
end

Instance Method Details

#error_messageObject



15
16
17
# File 'lib/validators/allow_user_locale_enabled_validator.rb', line 15

def error_message
  I18n.t("site_settings.errors.user_locale_not_enabled")
end

#valid_value?(val) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
# File 'lib/validators/allow_user_locale_enabled_validator.rb', line 8

def valid_value?(val)
  # only validate when enabling setting locale from headers
  return true if val == "f"
  # ensure that allow_user_locale is enabled
  SiteSetting.allow_user_locale
end