mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
refactor: move hex color validation to theme types
This commit is contained in:
parent
1fe6abb241
commit
a42975a71f
2 changed files with 5 additions and 6 deletions
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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>;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue