Class: GOBL::Operations::ValidationResult

Inherits:
Object
  • Object
show all
Defined in:
lib/gobl/operations/validation_result.rb

Overview

The result of a GOBL validation over a GOBL structure

Class Method Summary collapse

Instance Method Summary collapse

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

Parameters:

  • service_error (String)

Returns:



30
31
32
33
34
# File 'lib/gobl/operations/validation_result.rb', line 30

def self.from_service_error(service_error)
  message = service_error["message"] || service_error["key"]
  errors = message.split('; ')
  new errors
end

.validValidationResult

Builds a new ‘ValidationResult` object for a positive `validate` operation

Returns:



39
40
41
# File 'lib/gobl/operations/validation_result.rb', line 39

def self.valid
  new []
end

Instance Method Details

#errorsArray

The list of errors found in the GOBL structure

Returns:

  • (Array)


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

Returns:

  • (Boolean)


14
15
16
# File 'lib/gobl/operations/validation_result.rb', line 14

def valid?
  @errors.empty?
end