Update secret-router.ts

This commit is contained in:
Daniel Hougaard
2025-01-28 23:30:28 +01:00
parent ea28c374a7
commit ba03fc256b
+11 -4
View File
@@ -194,16 +194,23 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
return metadata; return metadata;
}) })
.superRefine((el, ctx) => { .superRefine((metadata, ctx) => {
if (el && !Array.isArray(el)) { if (metadata && !Array.isArray(metadata)) {
ctx.addIssue({ ctx.addIssue({
code: z.ZodIssueCode.custom, code: z.ZodIssueCode.custom,
message: "Invalid secretMetadata format. Correct format is key1:value1,key2:value2" message: "Invalid secretMetadata format. Correct format is key1:value1,key2:value2"
}); });
} }
if (el) { if (metadata) {
for (const item of el) { if (metadata.length > 10) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: "You can only filter by up to 10 metadata fields"
});
}
for (const item of metadata) {
if (!item.key || !item.value) { if (!item.key || !item.value) {
ctx.addIssue({ ctx.addIssue({
code: z.ZodIssueCode.custom, code: z.ZodIssueCode.custom,