Class: Schemurai::Result
- Inherits:
-
Object
- Object
- Schemurai::Result
- Defined in:
- lib/schemurai.rb,
sig/schemurai.rbs
Overview
The detailed result of validating one instance.
Instance Attribute Summary collapse
-
#errors ⇒ Array[ValidationError]
readonly
The frozen array of ValidationError objects.
Instance Method Summary collapse
-
#initialize(errors) ⇒ Result
constructor
Creates a result from an array of ValidationError objects.
-
#valid? ⇒ Boolean
(also: #success?)
Returns whether the instance passed validation.
Constructor Details
#initialize(errors) ⇒ Result
Creates a result from an array of ValidationError objects.
58 59 60 |
# File 'lib/schemurai.rb', line 58 def initialize(errors) @errors = errors.freeze end |
Instance Attribute Details
#errors ⇒ Array[ValidationError] (readonly)
The frozen array of ValidationError objects. It is empty when validation succeeds.
55 56 57 |
# File 'lib/schemurai.rb', line 55 def errors @errors end |
Instance Method Details
#valid? ⇒ Boolean Also known as: success?
Returns whether the instance passed validation.
63 64 65 |
# File 'lib/schemurai.rb', line 63 def valid? errors.empty? end |