Class: OpenapiFirst::ValidationResult

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataObject

Returns the value of attribute data

Returns:

  • (Object)

    the current value of data



4
5
6
# File 'lib/openapi_first/validation_result.rb', line 4

def data
  @data
end

#outputObject

Returns the value of attribute output

Returns:

  • (Object)

    the current value of output



4
5
6
# File 'lib/openapi_first/validation_result.rb', line 4

def output
  @output
end

#schemaObject

Returns the value of attribute schema

Returns:

  • (Object)

    the current value of schema



4
5
6
# File 'lib/openapi_first/validation_result.rb', line 4

def schema
  @schema
end

Instance Method Details

#error?Boolean

Returns:

  • (Boolean)


6
# File 'lib/openapi_first/validation_result.rb', line 6

def error? = !output['valid']

#messageObject

Returns a message that is used in exception messages.



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

def message
  return if valid?

  (output['errors']&.map { |e| e['error'] }&.join('. ') || output['error'])&.concat('.')
end

#valid?Boolean

Returns:

  • (Boolean)


5
# File 'lib/openapi_first/validation_result.rb', line 5

def valid? = output['valid']