Class: Attestor::Report
- Inherits:
-
Object
- Object
- Attestor::Report
- Defined in:
- lib/attestor/report.rb
Overview
Describes the result, returned by safe validation
Instance Attribute Summary collapse
-
#error ⇒ Attestor::InvalidError?
readonly
The exception raised by validation.
-
#object ⇒ Object
readonly
The object being validated.
Instance Method Summary collapse
-
#initialize(object, error = nil) ⇒ Report
constructor
A new instance of Report.
-
#invalid? ⇒ Boolean
Checks whether validation fails.
-
#messages ⇒ Array<String>
Returns the list of error messages.
-
#valid? ⇒ Boolean
Checks whether validation passes.
Constructor Details
#initialize(object, error = nil) ⇒ Report
Returns a new instance of Report.
9 10 11 12 13 |
# File 'lib/attestor/report.rb', line 9 def initialize(object, error = nil) @object = object @error = error freeze end |
Instance Attribute Details
#error ⇒ Attestor::InvalidError? (readonly)
The exception raised by validation
26 27 28 |
# File 'lib/attestor/report.rb', line 26 def error @error end |
#object ⇒ Object (readonly)
The object being validated
19 20 21 |
# File 'lib/attestor/report.rb', line 19 def object @object end |
Instance Method Details
#invalid? ⇒ Boolean
Checks whether validation fails
38 39 40 |
# File 'lib/attestor/report.rb', line 38 def invalid? !valid? end |
#messages ⇒ Array<String>
Returns the list of error messages
45 46 47 |
# File 'lib/attestor/report.rb', line 45 def error ? error. : [] end |
#valid? ⇒ Boolean
Checks whether validation passes
31 32 33 |
# File 'lib/attestor/report.rb', line 31 def valid? error.blank? end |