mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-31 06:41:03 +00:00
refactor: move hex color validation to theme types
This commit is contained in:
@@ -32,8 +32,3 @@ export const isPortableVersion = () => {
|
|||||||
|
|
||||||
export const normalizePath = (str: string) =>
|
export const normalizePath = (str: string) =>
|
||||||
path.posix.normalize(str).replace(/\\/g, "/");
|
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);
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import { isValidHexColor } from "@main/helpers";
|
|
||||||
import { z } from "zod";
|
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);
|
const hexColorSchema = z.string().refine(isValidHexColor);
|
||||||
type HexColorType = z.infer<typeof hexColorSchema>;
|
type HexColorType = z.infer<typeof hexColorSchema>;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user