byCodemod

Add Zod Validation

/icons/calendar.svg

Last update

Jun 5, 2024

Add zod validation to query parsing.

Examples

Before

const query = buildQuery(props.location?.search ?? '');
const someParam = query?.['some-param'] === 'true';

After

import { z } from 'zod';
const querySchema = z.object({
'some-param': z.string(),
});
const query = buildQuery(props.location?.search ?? '');
const parsedQuery = querySchema.parse(query);
const someParam = parsedQuery['some-param'] === 'true';

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now