Class: Mayaml::MailAccount::TypeValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/mayaml/mail_account/type_validator.rb

Constant Summary collapse

VALID_TYPES =
%i[imap pop3 imapssl pop3ssl].freeze

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ TypeValidator

Returns a new instance of TypeValidator.



25
26
27
28
# File 'lib/mayaml/mail_account/type_validator.rb', line 25

def initialize(type)
  @type = convert_type(type)
  errors << "Mail account type is invalid. Allowed types: #{valid_types}." unless valid_type?
end

Instance Method Details

#errorsObject



34
35
36
# File 'lib/mayaml/mail_account/type_validator.rb', line 34

def errors
  @errors ||= []
end

#valid?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/mayaml/mail_account/type_validator.rb', line 30

def valid?
  errors.empty?
end