refactor: remove central validation export to improve typescript performance (#2810)

* refactor: remove central validation export to improve typescript performance

* fix: missing package exports change in validation package

* chore: address pull request feedback
This commit is contained in:
Meier Lukas
2025-04-06 12:37:28 +02:00
committed by GitHub
parent c1cd563048
commit 75ba3f2ae7
81 changed files with 450 additions and 582 deletions

View File

@@ -1,6 +1,15 @@
import { z } from "zod";
const manageAppSchema = z.object({
export const appHrefSchema = z
.string()
.trim()
.url()
.regex(/^https?:\/\//) // Only allow http and https for security reasons (javascript: is not allowed)
.or(z.literal(""))
.transform((value) => (value.length === 0 ? null : value))
.nullable();
export const appManageSchema = z.object({
name: z.string().trim().min(1).max(64),
description: z
.string()
@@ -9,14 +18,7 @@ const manageAppSchema = z.object({
.transform((value) => (value.length === 0 ? null : value))
.nullable(),
iconUrl: z.string().trim().min(1),
href: z
.string()
.trim()
.url()
.regex(/^https?:\/\//) // Only allow http and https for security reasons (javascript: is not allowed)
.or(z.literal(""))
.transform((value) => (value.length === 0 ? null : value))
.nullable(),
href: appHrefSchema,
pingUrl: z
.string()
.trim()
@@ -27,12 +29,8 @@ const manageAppSchema = z.object({
.nullable(),
});
const editAppSchema = manageAppSchema.and(z.object({ id: z.string() }));
export const appCreateManySchema = z
.array(appManageSchema.omit({ iconUrl: true }).and(z.object({ iconUrl: z.string().min(1).nullable() })))
.min(1);
export const appSchemas = {
manage: manageAppSchema,
createMany: z
.array(manageAppSchema.omit({ iconUrl: true }).and(z.object({ iconUrl: z.string().min(1).nullable() })))
.min(1),
edit: editAppSchema,
};
export const appEditSchema = appManageSchema.and(z.object({ id: z.string() }));