Skip to content

Commit 75b4f51

Browse files
author
Petr Kachanovsky
committed
fix: change unique items default to true
1 parent 47eb6ff commit 75b4f51

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

adminforth/spa/src/components/ResourceForm.vue

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const columnError = (column) => {
116116
return t('Invalid JSON');
117117
}
118118
} else if (column.isArray?.enabled) {
119-
if (column.isArray.uniqueItems) {
119+
if (!column.isArray.allowDuplicateItems) {
120120
if (currentValues.value[column.name].filter((value, index, self) => self.indexOf(value) !== index).length > 0) {
121121
return t('Array cannot contain duplicate items');
122122
}
@@ -149,23 +149,23 @@ const validateValue = (type, value, column) => {
149149
return t('This field must be longer than {minLength} characters', { minLength: column.minLength });
150150
}
151151
}
152-
// if (['integer', 'decimal', 'float'].includes(type)) {
153-
// if (column.minValue !== undefined
154-
// && value !== null
155-
// && value < column.minValue
156-
// ) {
157-
// return t('This field must be greater than {minValue}', { minValue: column.minValue });
158-
// }
159-
// if (column.maxValue !== undefined && value > column.maxValue) {
160-
// return t('This field must be less than {maxValue}', { maxValue: column.maxValue });
161-
// }
162-
// }
163-
// if (value && column.validation) {
164-
// const error = applyRegexValidation(value, column.validation);
165-
// if (error) {
166-
// return error;
167-
// }
168-
// }
152+
if (['integer', 'decimal', 'float'].includes(type)) {
153+
if (column.minValue !== undefined
154+
&& value !== null
155+
&& value < column.minValue
156+
) {
157+
return t('This field must be greater than {minValue}', { minValue: column.minValue });
158+
}
159+
if (column.maxValue !== undefined && value > column.maxValue) {
160+
return t('This field must be less than {maxValue}', { maxValue: column.maxValue });
161+
}
162+
}
163+
if (value && column.validation) {
164+
const error = applyRegexValidation(value, column.validation);
165+
if (error) {
166+
return error;
167+
}
168+
}
169169
170170
return null;
171171
};

adminforth/types/Common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,9 +581,9 @@ export interface AdminForthResourceColumnInputCommon {
581581
*/
582582
itemType: AdminForthDataTypes,
583583
/**
584-
* If enabled, AdminForth will allow to add only unique items to the array.
584+
* If enabled, AdminForth will allow to add items with the same value.
585585
*/
586-
uniqueItems?: boolean,
586+
allowDuplicateItems?: boolean,
587587
},
588588

589589
/**

0 commit comments

Comments
 (0)