Skip to content

Commit

Permalink
fix: issue with undefined values bubbling up
Browse files Browse the repository at this point in the history
  • Loading branch information
MacQSL committed Dec 20, 2024
1 parent 101010a commit db11a27
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
11 changes: 9 additions & 2 deletions api/src/openapi/schemas/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const CSVErrorSchema: OpenAPIV3.SchemaObject = {
title: 'CSV validation error object',
type: 'object',
additionalProperties: false,
required: ['error', 'solution', 'row', 'cell', 'header'],
required: ['error', 'solution', 'values', 'cell', 'header', 'row'],
properties: {
error: {
description: 'The error message',
Expand All @@ -34,7 +34,14 @@ export const CSVErrorSchema: OpenAPIV3.SchemaObject = {
},
cell: {
description: 'The CSV cell value',
oneOf: [{ type: 'string' }, { type: 'number' }],
oneOf: [
{
type: 'string'
},
{
type: 'number'
}
],
nullable: true
},
header: {
Expand Down
6 changes: 3 additions & 3 deletions api/src/utils/csv-utils/csv-config-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ export const executeValidateCell = (
mutableErrors.push({
error: error.error,
solution: error.solution,
values: error.values,
cell: error.cell === undefined ? params.cell : error.cell, // Use cell value if intentionally null
header: error.header === undefined ? params.header : error.header, // Use header value if intentionally null
values: error.values ?? [],
cell: (error.cell === undefined ? params.cell : error.cell) ?? null, // Use cell value if intentionally null
header: (error.header === undefined ? params.header : error.header) ?? null, // Use header value if intentionally null
row: error.row ?? params.rowIndex + 2 // headers: 1, data row: 2
});
});
Expand Down
2 changes: 1 addition & 1 deletion app/src/utils/file-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface CSVError {
header: string | null;
cell: string | number | null;
row: number;
values?: Array<string | number>;
values: Array<string | number>;
}

export interface CSVValidationError {
Expand Down

0 comments on commit db11a27

Please sign in to comment.