mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
2.1 KiB
2.1 KiB
Changelog
[Unreleased]
[1.5.0] - 2026-11-02
Added
- Initial release:
compile(schema, options)validates JSON Schema drafts 2020-12 and 7 withoutevalornew Function, compiling a schema once into plain closures.Validator.checkis the boolean check (a type guard for schemas built with the builders),Validator.errorsreports each failure with a JSON Pointer path. Format checks are in the optional@earendil-works/pi-schema/formatsentry point. - Schema builders (
str,num,int,bool,nul,unknown,lit,oneOf,obj,opt,arr,tuple,map,union,nullable,bytes) that return plain JSON Schema typed with the values it accepts (Static<typeof schema>). compile(schema, { coerce: true })addscoerce(value)andparse(value)for loosely typed input such as a model's tool call arguments: optionalnulls dropped, TypeBox 1.3.27'sValue.Convertrules keyed on JSON Schema keywords (numeric strings,"true", single values to arrays,const/enummembers, union branches), then Ajv-style primitive coercion bytype.coercecopies only the paths it changes and returns the input itself when nothing changes;parsecoerces, then checks. Validators compiled without the option have neither; the README lists every rule.Staticalso types TypeBox-built schemas, from TypeBox 1.x's type shapes and without importing TypeBox: String, Number, Integer, Boolean, Null, Literal, Array, Object (withType.OptionalandType.Readonlyproperties), Union, Record, Unsafe, Unknown and Any give TypeBox's static type; other TypeBox kinds giveunknown.unresolvedRefs: "reject"compiles a$refthat names nothing asfalse(the error isunresolved reference <ref>) instead of throwing, for schemas whose references may dangle.formatsalso checksurlandjson-pointer-uri-fragment, as TypeBox and ajv-formats do.npm run benchcompares conformance, speed (with and without eval), setup cost, memory and bundle size with ata-validator (generated code and its interpreter), Ajv, Zod (native schemas, andz.fromJSONSchemafor the test suite), TypeBox, @cfworker/json-schema and omptype.