Class: Ollama::SchemaValidator
- Inherits:
-
Object
- Object
- Ollama::SchemaValidator
- Defined in:
- lib/ollama/schema_validator.rb
Overview
Validates JSON data against JSON Schema
For agent-grade usage, enforces strict schemas by default:
-
additionalProperties: false (unless explicitly set)
-
Prevents LLMs from adding unexpected fields
Class Method Summary collapse
Class Method Details
.validate!(data, schema) ⇒ Object
13 14 15 16 17 |
# File 'lib/ollama/schema_validator.rb', line 13 def self.validate!(data, schema) JSON::Validator.validate!(prepare_schema(schema), data) rescue JSON::Schema::ValidationError => e raise SchemaViolationError, e. end |