mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-18 04:58:28 +00:00
10 lines
468 B
TypeScript
10 lines
468 B
TypeScript
import { z } from "zod";
|
|
|
|
export const CASL_ACTION_SCHEMA_NATIVE_ENUM = <ACTION extends z.EnumLike>(actions: ACTION) =>
|
|
z
|
|
.union([z.nativeEnum(actions), z.nativeEnum(actions).array().min(1)])
|
|
.transform((el) => (typeof el === "string" ? [el] : el));
|
|
|
|
export const CASL_ACTION_SCHEMA_ENUM = <ACTION extends z.EnumValues>(actions: ACTION) =>
|
|
z.union([z.enum(actions), z.enum(actions).array().min(1)]).transform((el) => (typeof el === "string" ? [el] : el));
|