Const
import * as fc from 'fast-check'
import * as v from 'valibot'
import { vxTest } from '@traversable/valibot-test'
const [seed] = fc.sample(vxTest.SeedInvalidDataGenerator, 1)
const ValibotSchema = vxTest.seedToSchema(seed)
const dataset = fc.sample(vxTest.seedToInvalidData(seed), 5)
const results = dataset.map((pt) => ValibotSchema.safeParse(pt).success)
console.log(results) // => [false, false, false, false, false]
vxTest.SeedInvalidDataGenerator
A seed generator that can be interpreted to produce reliably invalid data.
This was originally developed to test for parity between various schema libraries.
Note that certain schemas make generating invalid data impossible (like v.any
v.any
). For this reason, those schemas are not seeded.To see the list of excluded schemas, see seedsThatPreventGeneratingInvalidData
vxTest.seedsThatPreventGeneratingInvalidData
.See also:
vxTest.SeedValidDataGenerator