Readme

This val demonstrates how TypeBox objects are interchangeable with JSON Schema objects - if you run JSON.stringify() on one of them, you immediately get a JSON Schema validator.

They do, in memory, have additional methods and information, but their easy conversion to JSON Schema objects is a major win.

1
2
3
4
5
6
7
8
import { Type } from "npm:@sinclair/typebox"
const querystring = Type.Object({
v: Type.Optional(Type.Integer({ minimum: 0 })),
})
console.log(JSON.stringify(querystring))
// {"type":"object","properties":{"v":{"minimum":0,"type":"integer"}}}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
July 15, 2024