Class: Trane::ContractValidator
- Inherits:
-
Object
- Object
- Trane::ContractValidator
- Defined in:
- lib/trane/contract_validator.rb
Class Method Summary collapse
-
.validate_response!(response_def, result, registry, mode:) ⇒ Object
Validate that a serialized result conforms to the response definition.
Class Method Details
.validate_response!(response_def, result, registry, mode:) ⇒ Object
Validate that a serialized result conforms to the response definition.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/trane/contract_validator.rb', line 13 def self.validate_response!(response_def, result, registry, mode:) violations = collect_violations(response_def.fields, result, registry, prefix: "") return if violations.empty? = "Trane contract violations (status #{response_def.status}):\n #{violations.join("\n ")}" case mode when :raise raise ContractViolation, when :log Trane.log_warning() end end |