From a42975a71fd805f4ecc5b0ef9ac768e421d28c39 Mon Sep 17 00:00:00 2001 From: Hachi-R Date: Wed, 29 Jan 2025 03:52:54 -0300 Subject: [PATCH] refactor: move hex color validation to theme types --- src/main/helpers/index.ts | 5 ----- src/types/theme.types.ts | 6 +++++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/helpers/index.ts b/src/main/helpers/index.ts index 99393d6c..163fb23a 100644 --- a/src/main/helpers/index.ts +++ b/src/main/helpers/index.ts @@ -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); -}; diff --git a/src/types/theme.types.ts b/src/types/theme.types.ts index 6db5eb84..e45b8062 100644 --- a/src/types/theme.types.ts +++ b/src/types/theme.types.ts @@ -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;