Documentation
¶
Overview ¶
Package typebox ports the parts of TypeBox 1.3.27 Value that PiG needs over JSON Schema data: Check, Errors, Clean, Default and Clone, with the format registry and the keyword spellings TypeBox accepts.
Index ¶
- func Check(schema, value any) bool
- func Clean(schema, value any) any
- func Clone(value any) any
- func CompilePattern(pattern string) (*regexp.Regexp, error)
- func CompilerSchema(value any) any
- func Default(schema, value any) any
- func Formats() map[string]func(string) bool
- func Plain(value any) any
- func RegisterFormats(compiler *jsonschema.Compiler)
- type ValueError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check is Value.Check: whether value matches schema. A schema the validator cannot compile matches nothing.
func Clean ¶
Clean is Value.Clean (value/clean): it removes the properties and tuple elements schema does not evaluate. It mutates value and returns the result.
func Clone ¶
Clone is Value.Clone: a deep copy of a JSON value; objects keep their kind (map or ordered object).
func CompilePattern ¶
CompilePattern is regexp.Compile for a schema's pattern text (patternProperties keys and the like), cached so a schema checked again does not compile its patterns again. A *regexp.Regexp is safe for concurrent use.
func CompilerSchema ¶
CompilerSchema translates the positional items and dependencies TypeBox accepts alongside current JSON Schema keywords into their draft-2020 spellings for the validator, without changing the schema used for conversion or error traversal.
func Default ¶
Default is Value.Default (value/default): it fills absent values that have a schema default. It mutates value and returns the result; an absent root is passed as nil and returned as nil when schema gives it no default.
func Formats ¶
Formats returns the formats of typebox's registry that Pig ports, by name. Every call returns the same map.
func Plain ¶
Plain returns value with every *chordjson.Object as a map[string]any and every Go number as float64, the form the validator reads. Other values are returned as they are.
func RegisterFormats ¶
func RegisterFormats(compiler *jsonschema.Compiler)
RegisterFormats makes the compiler assert the typebox formats.
Types ¶
type ValueError ¶
ValueError is one error of Errors: the instance path of the failing value ("" for the root; member names appended unescaped, as TypeBox does) and the en_US message.