mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-27 17:00:54 +01:00
* chore(deps): update dependency eslint to v9 * chore: migrate eslint to v9 * fix: dependency issues * fix: unit tests not working * chore: disable lint check for Image component that does not work in ci * fix: lint issue --------- Co-authored-by: homarr-renovate[bot] <158783068+homarr-renovate[bot]@users.noreply.github.com> Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
12 lines
496 B
TypeScript
12 lines
496 B
TypeScript
import { z } from "zod";
|
|
|
|
type CouldBeReadonlyArray<T> = T[] | readonly T[];
|
|
|
|
export const zodEnumFromArray = <T extends string>(array: CouldBeReadonlyArray<T>) =>
|
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
z.enum([array[0]!, ...array.slice(1)]);
|
|
|
|
export const zodUnionFromArray = <T extends z.ZodTypeAny>(array: CouldBeReadonlyArray<T>) =>
|
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
z.union([array[0]!, array[1]!, ...array.slice(2)]);
|