refactor: move hex color validation to theme types

This commit is contained in:
Hachi-R 2025-01-29 03:52:54 -03:00
parent 1fe6abb241
commit a42975a71f
2 changed files with 5 additions and 6 deletions

View File

@ -32,8 +32,3 @@ export const isPortableVersion = () => {
export const normalizePath = (str: string) =>
path.posix.normalize(str).replace(/\\/g, "/");
export const isValidHexColor = (color: string): boolean => {
const hexColorRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
return hexColorRegex.test(color);
};

View File

@ -1,6 +1,10 @@
import { isValidHexColor } from "@main/helpers";
import { z } from "zod";
const isValidHexColor = (color: string): boolean => {
const hexColorRegex = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
return hexColorRegex.test(color);
};
const hexColorSchema = z.string().refine(isValidHexColor);
type HexColorType = z.infer<typeof hexColorSchema>;