Class: Phonelib::ValidationResult
- Inherits:
-
Object
- Object
- Phonelib::ValidationResult
- Defined in:
- lib/phonelib/validation_result.rb
Overview
Immutable outcome of validating a parsed phone against a rule set.
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#phone ⇒ Object
readonly
Returns the value of attribute phone.
-
#possibility ⇒ Object
readonly
Returns the value of attribute possibility.
Instance Method Summary collapse
- #error ⇒ Object
-
#initialize(phone, errors, possibility) ⇒ ValidationResult
constructor
A new instance of ValidationResult.
- #invalid? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(phone, errors, possibility) ⇒ ValidationResult
Returns a new instance of ValidationResult.
8 9 10 11 12 13 |
# File 'lib/phonelib/validation_result.rb', line 8 def initialize(phone, errors, possibility) @phone = phone @errors = Errors.new(errors) @possibility = possibility freeze end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
6 7 8 |
# File 'lib/phonelib/validation_result.rb', line 6 def errors @errors end |
#phone ⇒ Object (readonly)
Returns the value of attribute phone.
6 7 8 |
# File 'lib/phonelib/validation_result.rb', line 6 def phone @phone end |
#possibility ⇒ Object (readonly)
Returns the value of attribute possibility.
6 7 8 |
# File 'lib/phonelib/validation_result.rb', line 6 def possibility @possibility end |
Instance Method Details
#error ⇒ Object
23 24 25 |
# File 'lib/phonelib/validation_result.rb', line 23 def error errors.first end |
#invalid? ⇒ Boolean
19 20 21 |
# File 'lib/phonelib/validation_result.rb', line 19 def invalid? !valid? end |
#valid? ⇒ Boolean
15 16 17 |
# File 'lib/phonelib/validation_result.rb', line 15 def valid? errors.empty? end |