Skip to content

Commit 7d8342f

Browse files
committed
added regex validation of steam64 id and identityId
1 parent b8549ea commit 7d8342f

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/components/ConfigForm.vue

+1
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ function violDecr() {
196196
<FormMultiSelectModInput
197197
:name="'admins'"
198198
:tooltip="'default []'"
199+
:regEx="['^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$', '^[0-9]{17}$']"
199200
:readonly="props.readonly"
200201
v-model="server.config.game.admins"
201202
></FormMultiSelectModInput>

src/components/FormMultiSelectModInput.vue

+18-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ const props = defineProps({
66
readonly: Boolean,
77
name: String,
88
tooltip: String,
9-
optionalParam: Boolean
9+
optionalParam: Boolean,
10+
regEx: Array
1011
});
1112
const model = defineModel<string[] | undefined>({ required: true });
1213
@@ -27,6 +28,22 @@ watch(
2728
2829
function addItem() {
2930
const input: HTMLInputElement = document.getElementById(inputId) as HTMLInputElement;
31+
32+
if (props.regEx) {
33+
let successCounter = 0;
34+
props.regEx.forEach(element => {
35+
const regEx = new RegExp(element as string);
36+
const regExResult = regEx.exec(input.value);
37+
if (regExResult !== null) {
38+
successCounter++;
39+
}
40+
});
41+
if (successCounter === 0) {
42+
alert('Malformatted string. See reference for details.');
43+
return;
44+
}
45+
}
46+
3047
localOptions.value.push(input.value);
3148
input.value = '';
3249
assignNewValue();

0 commit comments

Comments
 (0)