Class: Prescient::Agent::SchemaValidator
- Inherits:
-
Object
- Object
- Prescient::Agent::SchemaValidator
- Defined in:
- lib/prescient/agent/schema_validator.rb
Overview
Validates the JSON-schema subset used by agent tools. rubocop:disable Metrics/ClassLength
Class Method Summary collapse
-
.validate!(schema, value) ⇒ Object
Validate a value against a schema.
Instance Method Summary collapse
-
#initialize(schema) ⇒ SchemaValidator
constructor
A new instance of SchemaValidator.
-
#validate!(value) ⇒ Object
Validate a value against this validator's schema.
Constructor Details
#initialize(schema) ⇒ SchemaValidator
Returns a new instance of SchemaValidator.
16 17 18 |
# File 'lib/prescient/agent/schema_validator.rb', line 16 def initialize(schema) @schema = schema.is_a?(Hash) ? schema : {} end |
Class Method Details
.validate!(schema, value) ⇒ Object
Validate a value against a schema.
12 13 14 |
# File 'lib/prescient/agent/schema_validator.rb', line 12 def self.validate!(schema, value) new(schema).validate!(value) end |
Instance Method Details
#validate!(value) ⇒ Object
Validate a value against this validator's schema.
23 24 25 26 |
# File 'lib/prescient/agent/schema_validator.rb', line 23 def validate!(value) validate_schema(@schema, value, []) value end |