Class: POP3PollingEnabledSettingValidator
- Inherits:
-
Object
- Object
- POP3PollingEnabledSettingValidator
- Defined in:
- lib/validators/pop3_polling_enabled_setting_validator.rb
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(opts = {}) ⇒ POP3PollingEnabledSettingValidator
constructor
A new instance of POP3PollingEnabledSettingValidator.
- #valid_value?(val) ⇒ Boolean
Constructor Details
#initialize(opts = {}) ⇒ POP3PollingEnabledSettingValidator
Returns a new instance of POP3PollingEnabledSettingValidator.
6 7 8 |
# File 'lib/validators/pop3_polling_enabled_setting_validator.rb', line 6 def initialize(opts = {}) @opts = opts end |
Instance Method Details
#error_message ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/validators/pop3_polling_enabled_setting_validator.rb', line 18 def if SiteSetting.pop3_polling_host.blank? I18n.t("site_settings.errors.pop3_polling_host_is_empty") elsif SiteSetting.pop3_polling_username.blank? I18n.t("site_settings.errors.pop3_polling_username_is_empty") elsif SiteSetting.pop3_polling_password.blank? I18n.t("site_settings.errors.pop3_polling_password_is_empty") elsif !authentication_works? I18n.t("site_settings.errors.pop3_polling_authentication_failed") end end |
#valid_value?(val) ⇒ Boolean
10 11 12 13 14 15 16 |
# File 'lib/validators/pop3_polling_enabled_setting_validator.rb', line 10 def valid_value?(val) # only validate when enabling polling return true if val == "f" # ensure we can authenticate SiteSetting.pop3_polling_host.present? && SiteSetting.pop3_polling_username.present? && SiteSetting.pop3_polling_password.present? && authentication_works? end |