mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-28 01:10:54 +01:00
* feat: update prettier configuration for print width * chore: apply code formatting to entire repository * fix: remove build files * fix: format issue --------- Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
10 lines
354 B
TypeScript
10 lines
354 B
TypeScript
import { z } from "zod";
|
|
|
|
type CouldBeReadonlyArray<T> = T[] | readonly T[];
|
|
|
|
export const zodEnumFromArray = <T extends string>(array: CouldBeReadonlyArray<T>) =>
|
|
z.enum([array[0]!, ...array.slice(1)]);
|
|
|
|
export const zodUnionFromArray = <T extends z.ZodTypeAny>(array: CouldBeReadonlyArray<T>) =>
|
|
z.union([array[0]!, array[1]!, ...array.slice(2)]);
|