Reproduction
- Run
$ npm run run at the terminal of below URL:
Detail
SSIA
Code
import { z } from 'zod'
import { generateMock } from '@anatine/zod-mock'
const schema = z.object({
next: z.number().int(), // the property 'next' will never be an int (be a float)
otherProps: z.number().int(), // other properties will be an int correctly
nested: z.object({
next: z.number().int(), // same as the above 'next' property
}),
})
const mock = generateMock(schema)
console.log(mock)
// $ npm run run
// {
// next: 0.4105653762107577,
// otherProps: 6368046635644351,
// nested: {
// next: 0.7659188017942997,
// },
// }
//
// $ npm run run
// {
// next: 0.5737404892986545,
// otherProps: 7990334772728833,
// nested: {
// next: 0.7744221806853101,
// },
// }
//
// $ npm run run
// {
// next: 0.19289757416562037,
// otherProps: 2205544041244906,
// nested: {
// next: 0.6761322483941822,
// },
// }
//
// $ npm run run
// {
// next: 0.04695642220068308,
// otherProps: 7606587734425456,
// nested: {
// next: 0.01717930105667087,
// },
// }
//
// $ npm run run
// {
// next: 0.2164101780277775,
// otherProps: 6981326417384630,
// nested: {
// next: 0.19683404773381707,
// },
// }
Correct state
generateMock(z.object({ next: z.number().int() })).next must be an int value.