Closed timdeschryver closed 1 year ago
Hi @timdeschryver I just came across your library (via your blog post) and found it quite useful.
For my project, I had to create a uuidCustomization
which looks like this:
import { v4 as uuidv4 } from 'uuid';
import {
createFixture,
type Customization
} from 'zod-fixture';
const uuidCustomization: Customization = {
condition: ({ type, propertName }) =>
type === 'string' && propertName === 'id',
generator: () => {
return uuidv4();
},
};
I wanted to know about the project's general state: Do you plan to continue development of this library? If yes, I thought of contributing UUIDs a default customization to zod-fixture.
Just let me know, if you would appreciate a contribution. However, I am quite new to typescript, so please bear with me, when I give it a try 😅.
Side note:
Although I know zod-fixture is purposed for use in test code, I wanted suggest to use the uuid
package, rather than using Math.random
for generating uuids. While the chance of collisions during a test is rather low, I just thought it would be a "cleaner" way then generating uuids "by hand".
👋 Hey @franok we would love a contribution. While the snippet works for your case, I'm think we should make the solution more versatile. We can make use of the shape to detect if a uuid is requested.
I didn't include a package to generate the uuid's too keep things as small as possible, but I agree that it would be better to make this more robust and use the suggested package.
@franok v1.2 just got released and it creates a uuid
when using z.string().uuid()
.
cool, thx 👍
@franok feel free to create a PR to replace the guid
implementation if you want.
Implement string-specific validations