Class: SpecForge::Forge::Runner::SchemaValidator
- Inherits:
-
Object
- Object
- SpecForge::Forge::Runner::SchemaValidator
- Defined in:
- lib/spec_forge/forge/runner/schema_validator.rb
Overview
Validates JSON structure against a schema definition
Validates that response data matches the expected types and structure defined in shape: or schema: blocks. Supports nested objects, arrays with patterns, and nullable types.
Instance Method Summary collapse
-
#initialize(data, schema) ⇒ SchemaValidator
constructor
Creates a new schema validator.
-
#validate! ⇒ void
Validates the data against the schema definition.
Constructor Details
#initialize(data, schema) ⇒ SchemaValidator
Creates a new schema validator
22 23 24 25 26 |
# File 'lib/spec_forge/forge/runner/schema_validator.rb', line 22 def initialize(data, schema) @data = data @schema = schema @failures = [] end |
Instance Method Details
#validate! ⇒ void
This method returns an undefined value.
Validates the data against the schema definition
35 36 37 38 39 |
# File 'lib/spec_forge/forge/runner/schema_validator.rb', line 35 def validate! check_schema(@data, @schema, path: "") raise Error::SchemaValidationFailure.new(@failures) if @failures.size > 0 end |