import { vx } from '@traversable/valibot'
let ex_01 = vx.fromJson({ abc: 'ABC', def: [] })
console.log(vx.toString(ex_01))
// => v.object({ abc: v.string(), def: v.array(v.unknown()) })
let ex_02 = vx.fromJson({ abc: false, def: [123] })
console.log(vx.toString(ex_02))
// => v.object({ abc: v.boolean(), def: v.array(v.number()) })
let ex_03 = vx.fromJson({ abc: 123, def: ['ABC', null] })
console.log(vx.toString(ex_03))
// => v.object({ abc: v.number(), def: v.array(v.union([v.string(), v.null()])) })
vx.fromJson
Convert a blob of JSON data into a valibot schema that represents that blob's greatest lower bound.
import { vx } from '@traversable/valibot'
let ex_01 = vx.fromJson({ abc: 'ABC', def: [] })
console.log(vx.toString(ex_01))
// => v.object({ abc: v.string(), def: v.array(v.unknown()) })
let ex_02 = vx.fromJson({ abc: false, def: [123] })
console.log(vx.toString(ex_02))
// => v.object({ abc: v.boolean(), def: v.array(v.number()) })
let ex_03 = vx.fromJson({ abc: 123, def: ['ABC', null] })
console.log(vx.toString(ex_03))
// => v.object({ abc: v.number(), def: v.array(v.union([v.string(), v.null()])) })
vx.fromJson.writeable
Convert a blob of JSON data into a stringified valibot schema that represents that blob's greatest lower bound.
import { vx } from '@traversable/valibot'
let ex_01 = vx.fromJson.writeable({ abc: 'ABC', def: [] })
console.log(ex_01)
// => v.object({ abc: v.string(), def: v.array(v.unknown()) })
let ex_02 = vx.fromJson.writeable({ abc: false, def: [123] })
console.log(ex_02)
// => v.object({ abc: v.boolean(), def: v.array(v.number()) })
let ex_03 = vx.fromJson.writeable({ abc: 123, def: ['ABC', null] })
console.log(ex_03)
// => v.object({ abc: v.number(), def: v.array(v.union([v.string(), v.null()])) })
vx.fromJson
Convert a blob of JSON data into a valibot schema that represents that blob's greatest lower bound.