Class: Insika::Workflow::Schema
- Inherits:
-
Object
- Object
- Insika::Workflow::Schema
- Defined in:
- lib/insika/workflow.rb
Overview
Zero-dependency instance validator for a plain JSON Schema Hash, speaking the
same safe subset (object/array/string/number/integer/boolean + enum) the
ToolDefinition validates its parameters against. It implements the SAME
#call(value) -> result{#success?, #errors} contract as dry-schema, so the
Definition treats both uniformly. Not a full JSON Schema engine (no
composition/$ref — the subset the insika supports everywhere); permissive on
unknown keys (JSON Schema's additionalProperties default).
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#json_schema ⇒ Object
readonly
Returns the value of attribute json_schema.
Class Method Summary collapse
-
.coerce(schema) ⇒ Object
nil -> nil; a callable (dry-schema / proc) -> as-is; a JSON Schema Hash -> wrapped.
Instance Method Summary collapse
- #call(value) ⇒ Object
-
#initialize(json_schema) ⇒ Schema
constructor
A new instance of Schema.
Constructor Details
#initialize(json_schema) ⇒ Schema
Returns a new instance of Schema.
101 102 103 104 105 106 107 |
# File 'lib/insika/workflow.rb', line 101 def initialize(json_schema) unless json_schema.is_a?(Hash) raise Insika::ValidationError, "workflow schema must be a JSON Schema object or a #call-able validator" end @json_schema = Insika::Coercion.deep_stringify(json_schema) end |
Instance Attribute Details
#json_schema ⇒ Object (readonly)
Returns the value of attribute json_schema.
99 100 101 |
# File 'lib/insika/workflow.rb', line 99 def json_schema @json_schema end |
Class Method Details
.coerce(schema) ⇒ Object
nil -> nil; a callable (dry-schema / proc) -> as-is; a JSON Schema Hash -> wrapped. Idempotent for an existing Schema (it is callable).
92 93 94 95 96 97 |
# File 'lib/insika/workflow.rb', line 92 def self.coerce(schema) return nil if schema.nil? return schema if schema.respond_to?(:call) new(schema) end |