Class: Philiprehberger::EmailValidator::Result
- Inherits:
-
Object
- Object
- Philiprehberger::EmailValidator::Result
- Defined in:
- lib/philiprehberger/email_validator/result.rb
Overview
Value object representing the outcome of an email validation.
Instance Attribute Summary collapse
-
#errors ⇒ Array<String>
readonly
List of validation error messages.
-
#warnings ⇒ Array<String>
readonly
List of non-fatal warning messages.
Instance Method Summary collapse
-
#initialize(errors: [], warnings: []) ⇒ Result
constructor
A new instance of Result.
-
#to_s ⇒ String
(also: #inspect)
String representation for debugging.
-
#valid? ⇒ Boolean
Whether the email passed all validation checks.
Constructor Details
#initialize(errors: [], warnings: []) ⇒ Result
Returns a new instance of Result.
21 22 23 24 25 |
# File 'lib/philiprehberger/email_validator/result.rb', line 21 def initialize(errors: [], warnings: []) @errors = errors.freeze @warnings = warnings.freeze freeze end |
Instance Attribute Details
#errors ⇒ Array<String> (readonly)
Returns list of validation error messages.
14 15 16 |
# File 'lib/philiprehberger/email_validator/result.rb', line 14 def errors @errors end |
#warnings ⇒ Array<String> (readonly)
Returns list of non-fatal warning messages.
17 18 19 |
# File 'lib/philiprehberger/email_validator/result.rb', line 17 def warnings @warnings end |
Instance Method Details
#to_s ⇒ String Also known as: inspect
String representation for debugging.
37 38 39 40 41 42 43 |
# File 'lib/philiprehberger/email_validator/result.rb', line 37 def to_s if valid? '#<EmailValidator::Result valid>' else "#<EmailValidator::Result invalid errors=#{@errors}>" end end |
#valid? ⇒ Boolean
Whether the email passed all validation checks.
30 31 32 |
# File 'lib/philiprehberger/email_validator/result.rb', line 30 def valid? @errors.empty? end |