refactor: replace io-ts with zod
This commit is contained in:
parent
fafaefa1fb
commit
28692962bc
161 changed files with 1450 additions and 2105 deletions
15
backend/src/utils/zColor.ts
Normal file
15
backend/src/utils/zColor.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import z from "zod";
|
||||
import { parseColor } from "./parseColor";
|
||||
import { rgbToInt } from "./rgbToInt";
|
||||
|
||||
export const zColor = z.string().transform((val, ctx) => {
|
||||
const parsedColor = parseColor(val);
|
||||
if (parsedColor == null) {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "Invalid color",
|
||||
});
|
||||
return z.NEVER;
|
||||
}
|
||||
return rgbToInt(parsedColor);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue