Documentation
¶
Overview ¶
Package jsonschema validates structured agent answers against the subset of JSON Schema the profile's schemas may use: type, properties, required, additionalProperties, enum, minLength, maxLength, minItems, maxItems, items, pattern (RE2) and description. Compile refuses every other keyword, naming the field.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("does not fit the schema")
ErrInvalid is wrapped by every error Validate returns.
var ErrSchema = errors.New("jsonschema: unsupported schema")
ErrSchema is wrapped by every error Compile returns.
var Keywords = []string{"type", "properties", "required", "additionalProperties", "enum", "minLength", "maxLength",
"minItems", "maxItems", "items", "pattern", "description"}
Keywords are the JSON Schema keywords Compile accepts.
var Types = []string{"object", "array", "string", "integer", "number", "boolean", "null"}
Types are the values of type Compile accepts.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Flat refuses an object nested below the top level, as the brief
// intent's extra schema must be.
Flat bool
}
Options narrow what Compile accepts.
type Property ¶
type Property struct {
Name string
// Type is the property's type.
Type string
// Items is the type of an array property's items.
Items string
// Enum are the string values of the property, or of its items.
Enum []string
// Source is the property's own schema bytes, which its field version
// hashes.
Source []byte
}
Property is one top-level property of a flat object schema, as a fact reads it.
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is a compiled schema.
func Compile ¶
Compile parses src, refusing a keyword outside Keywords or, with Flat, a nested object; the error names the field.
func (*Schema) Properties ¶
Properties are the top-level properties of an object schema, by name.
func (*Schema) Validate ¶
Validate checks a decoded JSON value against s; the error names the first field that does not fit.
func (*Schema) ValidateJSON ¶
ValidateJSON decodes raw and validates it.