mirror of
https://github.com/ajnart/homarr.git
synced 2026-02-27 17:00:54 +01:00
27 lines
668 B
TypeScript
27 lines
668 B
TypeScript
import { z } from "zod";
|
|
|
|
import { groupPermissionKeys } from "@homarr/definitions";
|
|
|
|
import { byIdSchema } from "./common";
|
|
import { zodEnumFromArray } from "./enums";
|
|
|
|
const createSchema = z.object({
|
|
name: z.string().trim().min(1).max(64),
|
|
});
|
|
|
|
const updateSchema = createSchema.merge(byIdSchema);
|
|
|
|
const savePermissionsSchema = z.object({
|
|
groupId: z.string(),
|
|
permissions: z.array(zodEnumFromArray(groupPermissionKeys)),
|
|
});
|
|
|
|
const groupUserSchema = z.object({ groupId: z.string(), userId: z.string() });
|
|
|
|
export const groupSchemas = {
|
|
create: createSchema,
|
|
update: updateSchema,
|
|
savePermissions: savePermissionsSchema,
|
|
groupUser: groupUserSchema,
|
|
};
|