fix issue with important message being empty

This commit is contained in:
Brandon Egger
2023-06-06 22:43:04 -05:00
parent 54701726cd
commit 31a6d18b4a
3 changed files with 48 additions and 12 deletions

View File

@ -13,6 +13,14 @@ import {
publicProcedure,
} from "~/server/api/trpc";
const emptyStringToUndefined = (val: string | undefined | null) => {
if (val?.length === 0) {
return undefined;
}
return val;
};
export const auditoryResourceRouter = createTRPCRouter({
byId: publicProcedure
.input(z.object({ id: z.string() }))
@ -41,7 +49,11 @@ export const auditoryResourceRouter = createTRPCRouter({
.object({
name: z.string().min(1),
required: z.boolean(),
notice: z.string().min(1).optional().nullable(),
notice: z
.string()
.optional()
.nullable()
.transform(emptyStringToUndefined),
})
.optional(),
ages: z