Const
Optional
options: OptionsOptional
overrides: Partial<import * as fc from 'fast-check'
import * as v from 'valibot'
import { vxTest } from '@traversable/valibot-test'
const Json = vxTest.SeedGenerator({ include: ['null', 'boolean', 'number', 'string', 'array', 'object'] })
const [jsonNumber, jsonObject, anyJson] = [
fc.sample(Json.number, 1)[0],
fc.sample(Json.object, 1)[0],
fc.sample(Json['*'], 1)[0],
] as const
console.log(JSON.stringify(jsonNumber))
// => [200,[2.96e-322,1,null,false,true]]
console.log(vxTest.toString(vxTest.seedToSchema(jsonNumber)))
// => v.pipe(v.number(), v.maxValue(2.96e-322), v.ltValue(1)
console.log(JSON.stringify(jsonObject))
// => [7500,[["n;}289K~",[250,[null,null]]]]]
console.log(vxTest.toString(vxTest.seedToSchema(jsonObject)))
// => v.object({ "n;}289K~": v.string() })
console.log(anyJson)
// => [250,[23,64]]
console.log(vxTest.toString(vxTest.seedToSchema(anyJson)))
// => v.pipe(v.string(), v.minValue(23), v.maxValue(64))
SeedGenerator
Pseudo-random seed generator.
The generator supports a wide range of discoverable configuration options 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:
SeedGenerator