Rebasely Beta: data may be purged

justintypescript-ultra-strict Public

Text · 12 lines · 434 B · at 9c48a39

import { z } from "zod";import { Ok, Err, type Result } from "@tsus/runtime";const RowSchema = z.object({ name: z.string().min(1), age: z.number().min(18) });export type Row = z.infer<typeof RowSchema>;export type RowError = "invalid row";export const validateRow = (input: unknown): Result<Row, RowError> => {  const outcome = RowSchema.safeParse(input);  return outcome.success ? Ok(outcome.data) : Err("invalid row");};