colinhacks / zod

TypeScript-first schema validation with static type inference
https://zod.dev
MIT License
33.92k stars 1.18k forks source link

cuid validation #3621

Open eminden opened 4 months ago

eminden commented 4 months ago

parse() function is not throwing an exception for this string cly63t164000245zw008pggon';select 1;

const idSchema = z.array(z.string().cuid(), {
    message: "Each ID must be a valid CUID",
}).optional();

try {
    idSchema.parse(params.folders);
} catch (error) {
    throw new Error('Invalid IDs');
}
eswarty commented 4 months ago

Hi! I was curious and tested your schema, but I wasn't able to repro the issue. It seems to throw an error for me as expected. I tried this zod playground and also tried running your code locally and both throw the expected error for me. Sorry that's not super helpful 🙁