Skip to content

Commit

Permalink
fix: single file collection
Browse files Browse the repository at this point in the history
can not be a union of just one schema
  • Loading branch information
davidenke committed Nov 13, 2024
1 parent 7581937 commit 33f9518
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/utils/transform.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ export function transformCollection(
const field = { name, fields, widget: 'object' as const };
return transformObjectField(field, zod);
});
// single file collection is just the result
if (results.length === 1) return results[0];
// multiple file collection is a union of all results
return {
cptime: `z.union([${results.map(({ cptime }) => cptime).join(', ')}])`,
runtime: zod.union(results.map(({ runtime }) => runtime) as any),
Expand Down

0 comments on commit 33f9518

Please sign in to comment.