Skip to content

Commit 8aaefd4

Browse files
Update apps/web/src/features/upload/utils.ts
refactor set sample data generation Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 0355f58 commit 8aaefd4

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

apps/web/src/features/upload/utils.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,15 +335,14 @@ function generateSampleData({
335335
return formatTypeInfo('number', isOptional);
336336
case 'ZodSet':
337337
try {
338-
let possibleEnumOutputs = 'SET(';
339-
for (const val of enumValues!) {
340-
possibleEnumOutputs += val + '/';
338+
if (!enumValues) {
339+
throw new Error('Missing enumValues for ZodSet');
341340
}
342-
possibleEnumOutputs = possibleEnumOutputs.slice(0, -1);
343-
possibleEnumOutputs += ', ...)';
341+
const enumString = enumValues.join('/');
342+
const possibleEnumOutputs = `SET(${enumString}, ...)`;
344343
return formatTypeInfo(possibleEnumOutputs, isOptional);
345-
} catch {
346-
throw new Error('Invalid Enum error');
344+
} catch (error) {
345+
throw new Error(`Failed to generate sample data for ZodSet: ${error.message}`);
347346
}
348347

349348
case 'ZodString':

0 commit comments

Comments
 (0)