T
TanStack•10mo ago
ratty-blush

How to reset search params when not validated?

How to completly clear search params when not passed validation? heres my validation:
const projectEstimateSearchSchema = z.object({
module: z.union([z.number(), z.string()]).optional(),
role: z.union([z.number(), z.string()]).optional(),
task: z.union([z.number(), z.string()]).optional(),
});
const projectEstimateSearchSchema = z.object({
module: z.union([z.number(), z.string()]).optional(),
role: z.union([z.number(), z.string()]).optional(),
task: z.union([z.number(), z.string()]).optional(),
});
when validation faile i want to clear my search params
3 Replies
ratty-blush
ratty-blushOP•10mo ago
and that my createFileRoute:
export const Route = createFileRoute(
'/_authorized/app/_layout/projects/$projectId/',
)({
loader: async ({
context: { queryClient, transformEstimateData },
params: { projectId },
}) => {
await queryClient.ensureQueryData(
projectEstimateQueryOptions(+projectId, transformEstimateData),
);
},
validateSearch: projectEstimateSearchSchema,
component: ProjectEstimate,
});
export const Route = createFileRoute(
'/_authorized/app/_layout/projects/$projectId/',
)({
loader: async ({
context: { queryClient, transformEstimateData },
params: { projectId },
}) => {
await queryClient.ensureQueryData(
projectEstimateQueryOptions(+projectId, transformEstimateData),
);
},
validateSearch: projectEstimateSearchSchema,
component: ProjectEstimate,
});
plain-purple
plain-purple•10mo ago
your validator would need to return an empty object and you would need to enable strict search mode
ratty-blush
ratty-blushOP•10mo ago
Thanks a lot! 🙂

Did you find this page helpful?