Class: GOBL::Operations::ValidationResult
- Inherits:
-
Object
- Object
- GOBL::Operations::ValidationResult
- Defined in:
- lib/gobl/operations/validation_result.rb
Overview
The result of a GOBL validation over a GOBL structure
Class Method Summary collapse
-
.from_service_error(service_error) ⇒ ValidationResult
Builds a new ‘ValidationResult` object resulted from parsing the service error response given as a parameter.
-
.valid ⇒ ValidationResult
Builds a new ‘ValidationResult` object for a positive `validate` operation.
Instance Method Summary collapse
-
#errors ⇒ Array
The list of errors found in the GOBL structure.
-
#initialize(errors) ⇒ ValidationResult
constructor
A new instance of ValidationResult.
-
#valid? ⇒ Boolean
Whether the GOBL structure were valid or not.
Constructor Details
#initialize(errors) ⇒ ValidationResult
Returns a new instance of ValidationResult.
7 8 9 |
# File 'lib/gobl/operations/validation_result.rb', line 7 def initialize(errors) @errors = errors end |
Class Method Details
.from_service_error(service_error) ⇒ ValidationResult
Builds a new ‘ValidationResult` object resulted from parsing the service
error response given as a parameter
30 31 32 33 34 |
# File 'lib/gobl/operations/validation_result.rb', line 30 def self.from_service_error(service_error) = service_error["message"] || service_error["key"] errors = .split('; ') new errors end |
.valid ⇒ ValidationResult
Builds a new ‘ValidationResult` object for a positive `validate` operation
39 40 41 |
# File 'lib/gobl/operations/validation_result.rb', line 39 def self.valid new [] end |
Instance Method Details
#errors ⇒ Array
The list of errors found in the GOBL structure
21 22 23 |
# File 'lib/gobl/operations/validation_result.rb', line 21 def errors @errors || [] end |
#valid? ⇒ Boolean
Whether the GOBL structure were valid or not
14 15 16 |
# File 'lib/gobl/operations/validation_result.rb', line 14 def valid? @errors.empty? end |