import { vx } from '@traversable/valibot'
let schema = vx.fromConstant({ abc: 'ABC', def: [1, 2, 3] })
// ^? let schema: v.BaseSchema<
// { readonly abc: "ABC", readonly def: readonly [1, 2, 3] },
// { readonly abc: "ABC", readonly def: readonly [1, 2, 3] },
// v.BaseIssue<unknown>
// >
console.log(vx.toString(schema))
// =>
// v.object({
// abc: v.literal("ABC"),
// def: v.tuple([
// v.literal(1),
// v.literal(2),
// v.literal(3)
// ])
// })
vx.fromConstant
Convert a blob of JSON data into a valibot schema that represents that blob's least upper bound.
import { vx } from '@traversable/valibot'
let schema = vx.fromConstant({ abc: 'ABC', def: [1, 2, 3] })
// ^? let schema: v.BaseSchema<
// { readonly abc: "ABC", readonly def: readonly [1, 2, 3] },
// { readonly abc: "ABC", readonly def: readonly [1, 2, 3] },
// v.BaseIssue<unknown>
// >
console.log(vx.toString(schema))
// =>
// v.object({
// abc: v.literal("ABC"),
// def: v.tuple([
// v.literal(1),
// v.literal(2),
// v.literal(3)
// ])
// })
vx.fromConstant
Convert a blob of JSON data into a valibot schema that represents that blob's least upper bound.