mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-06-08 00:05:01 +00:00
15 lines
394 B
TypeScript
15 lines
394 B
TypeScript
import z from "zod/v4";
|
|
import { parseColor } from "./parseColor.js";
|
|
import { rgbToInt } from "./rgbToInt.js";
|
|
|
|
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);
|
|
});
|