Reputation: 1149
We can create Zod object that validates an object against the keys that are defined in the schema, but I only want to validate if the key is a string not if the key == something
In typescript we can achieve this by using
Record<string, string>;
But in zod, I tried this one
const data = z.object({
[z.string()]: z.string(),
});
But it's not working
Upvotes: 57
Views: 52040