Class: DefaultComposerCategoryValidator

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

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ DefaultComposerCategoryValidator

Returns a new instance of DefaultComposerCategoryValidator.



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

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

Instance Method Details

#error_messageObject



16
17
18
# File 'lib/validators/default_composer_category_validator.rb', line 16

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

#valid_value?(val) ⇒ Boolean

Returns:

  • (Boolean)


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

def valid_value?(val)
  category_id = val.to_i
  unless SiteSetting.allow_uncategorized_topics
    return false if category_id == SiteSetting.uncategorized_category_id
  end
  true
end