Const
import * as fc from 'fast-check'
import * as v from 'valibot'
import { vxTest } from '@traversable/valibot-test'
const tenSchemas = fc.sample(vxTest.SchemaGenerator({
include: ['null', 'boolean', 'number', 'string', 'array', 'object']
}), 10)
tenSchemas.forEach((s) => console.log(vxTest.toString(s)))
// => v.number()
// => v.pipe(v.string(), v.minValue(9.1e-53))
// => v.null()
// => v.array(v.boolean())
// => v.boolean()
// => v.object({ "": v.object({ "/d2P} {/": v.boolean() }), "svH2]L'x": v.pipe(v.number(), v.ltValue(-65536)) })
// => v.null()
// => v.string()
// => v.array(v.array(v.null()))
// => v.object({ "y(Qza": v.boolean(), "G1S\\U 4Y6i": v.object({ "YtO3]ia0cM": v.boolean() }) })
vxTest.SchemaGenerator
A valibot schema generator that can be interpreted to produce an arbitrary valibot schema.
The generator supports a wide range of configuration options that are discoverable via the optional
options
argument.Many of those options are forwarded to the corresponding
fast-check
arbitrary.Note: support for
options.minDepth
is experimental. If you use it, be advised that even with a minimum depth of 1, the schemas produced will be quite large. Using this option in your CI/CD pipeline is not recommended.See also:
vxTest.SeedGenerator