refactor(ui): org state in prep for new flow

This commit is contained in:
psychedelicious
2025-05-21 16:26:58 +10:00
parent c9cd0a87be
commit 5f2f12f803
6 changed files with 145 additions and 130 deletions

View File

@@ -0,0 +1,10 @@
import type { z } from 'zod';
/**
* Helper to create a type guard from a zod schema. The type guard will infer the schema's TS type.
* @param schema The zod schema to create a type guard from.
* @returns A type guard function for the schema.
*/
export const buildZodTypeGuard = <T extends z.ZodTypeAny>(schema: T) => {
return (val: unknown): val is z.infer<T> => schema.safeParse(val).success;
};