Skip to content

Commit 04e56a8

Browse files
authored
Merge pull request #65 from devforth/add-duplicate-column-name-check
fix: add duplicate column name check to config validation
2 parents eb493f3 + e14a28d commit 04e56a8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

adminforth/modules/configValidator.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,14 @@ export default class ConfigValidator implements IConfigValidator {
321321
if (!res.columns) {
322322
res.columns = [];
323323
}
324-
res.columns = res.columns.map((inCol: AdminForthResourceColumnInputCommon) => {
324+
res.columns = res.columns.map((inCol: AdminForthResourceColumnInputCommon, inColIndex) => {
325325
const col: Partial<AdminForthResourceColumn> = { ...inCol, required: undefined, editingNote: undefined };
326326

327+
// check for duplicate column names
328+
if (res.columns.findIndex((c) => c.name === col.name) !== inColIndex) {
329+
errors.push(`Resource "${res.resourceId}" has duplicate column name "${col.name}"`);
330+
}
331+
327332
col.label = col.label || guessLabelFromName(col.name);
328333
//define default sortable
329334
if (!Object.keys(col).includes('sortable')) { col.sortable = !col.virtual; }

0 commit comments

Comments
 (0)