Skip to content

Commit d55bb58

Browse files
committed
add type checking
1 parent 82ec2fd commit d55bb58

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

frontend/src/api/service/ConfigurationService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default class ConfigurationService {
2323

2424
static saveConfiguration(
2525
configuration: ConfigurationItemDTO[]
26-
): Promise<ConfigurationDTO> {
26+
): Promise<ConfigurationDTO[]> {
2727
return FetchService.postData(
2828
configuration,
2929
`${this.ENDPOINT}/all`,

frontend/src/components/config/ConfigApplication.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
>
1414
<v-card-text class="pb-16">
1515
<div v-for="(items, category) in groupedConfig" :key="category" class="mb-6">
16-
<h3 class="text-h6 mb-3">{{ category.toLocaleUpperCase() }}</h3>
16+
<h3 class="text-h6 mb-3">{{ category.toUpperCase() }}</h3>
1717
<v-list>
1818
<v-list-item v-for="item in items" :key="item.id">
1919
<v-text-field
@@ -22,6 +22,7 @@
2222
variant="outlined"
2323
density="compact"
2424
class="pt-2"
25+
:rules="[validateDatatype(item)]"
2526
/>
2627
</v-list-item>
2728
</v-list>
@@ -58,6 +59,22 @@ const groupedConfig = computed(() => {
5859
}, {} as Record<string, ConfigurationItemDTO[]>);
5960
});
6061
62+
function validateDatatype(item: ConfigurationItemDTO) {
63+
return (value: string) => {
64+
if (!value) return true;
65+
if (item.datatype === 'INTEGER') {
66+
return /^-?\d+$/.test(value) || 'Muss eine Ganzzahl sein';
67+
}
68+
if (item.datatype === 'DOUBLE') {
69+
return /^-?\d+(\.\d+)?$/.test(value) || 'Muss eine Zahl sein';
70+
}
71+
if (item.datatype === 'BOOLEAN') {
72+
return /^(true|false)$/i.test(value) || 'Muss true oder false sein';
73+
}
74+
return true;
75+
};
76+
}
77+
6178
loadConfigValues();
6279
6380
function loadConfigValues() {

0 commit comments

Comments
 (0)