Class: OpenapiFirst::Schema::ValidationResult

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_first/schema/validation_result.rb

Overview

Result of validating data against a schema. Return value of Schema#validate.

Instance Method Summary collapse

Constructor Details

#initialize(validation) ⇒ ValidationResult

Returns a new instance of ValidationResult.



9
10
11
# File 'lib/openapi_first/schema/validation_result.rb', line 9

def initialize(validation)
  @validation = validation
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


13
# File 'lib/openapi_first/schema/validation_result.rb', line 13

def error? = @validation.any?

#errorsObject

Returns an array of ValidationError objects.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/openapi_first/schema/validation_result.rb', line 16

def errors
  @errors ||= @validation.map do |err|
    ValidationError.new(
      message: err['error'],
      data_pointer: err['data_pointer'],
      schema_pointer: err['schema_pointer'],
      type: err['type'],
      details: err['details']
    )
  end
end