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.
options
Many of those options are forwarded to the corresponding fast-check arbitrary.
fast-check
See also:
vxTest.SeedGenerator
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() }) }) Copy
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.See also:
vxTest.SeedGenerator
Example