Skip to content

Commit 2d8d007

Browse files
committed
feat: deal with zod3 empty optional record array entry
1 parent abcbcac commit 2d8d007

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

apps/web/src/utils/upload.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,14 @@ function extractRecordArrayEntry(entry: string): { [key: string]: string }[] {
152152
const records: { [key: string]: string } = {};
153153
recordsList.forEach((rawRecord, i) => {
154154
const [recordKey, recordValue] = rawRecord.split(':').map((s) => s.trim());
155-
if (!(recordKey && recordValue)) {
155+
if (!recordKey) {
156156
throw new UploadError({
157157
en: `Malformed record at index ${i}`,
158158
fr: `Enregistrement mal formé à l'index ${i}`
159159
});
160160
}
161-
records[recordKey] = recordValue;
161+
//recordValue can be empty if the value is optional
162+
records[recordKey] = recordValue!;
162163
});
163164
return records;
164165
});
@@ -397,6 +398,7 @@ export namespace Zod3 {
397398
fr: "Les clés ou valeurs du tableau d'enregistrements n'existent pas"
398399
});
399400
}
401+
400402
return extractRecordArrayEntry(entry).map((parsedRecord) => {
401403
const result: { [key: string]: unknown } = {};
402404
convertResult.multiKeys!.forEach((key, index) => {

0 commit comments

Comments
 (0)