diff --git a/frontend/src/app/component/einstellungen/editieren/editieren.component.html b/frontend/src/app/component/einstellungen/editieren/editieren.component.html
index d1d0c3b..736d33b 100644
--- a/frontend/src/app/component/einstellungen/editieren/editieren.component.html
+++ b/frontend/src/app/component/einstellungen/editieren/editieren.component.html
@@ -6,13 +6,15 @@
Vollständige URL des RSS-Feeds
-
+
+ Geben Sie eine valide URL ein.
- Gesuchte Stichwörter
+ Gesuchte Stichworte
+ Maximal 3 Wörter und jedes Wort mindestens 3 Zeichen
Alle Stichworte müssen enthalten sein
@@ -24,7 +26,7 @@
Die maximale Dateigröße ist {{feedForm.get('icon')?.getError('maxContentSize').maxSize | byteFormat}}
({{feedForm.get('icon')?.getError('maxContentSize').actualSize
- | byteFormat}}).
+ | byteFormat}})
diff --git a/frontend/src/app/component/einstellungen/editieren/editieren.component.ts b/frontend/src/app/component/einstellungen/editieren/editieren.component.ts
index 6abd452..15f2250 100644
--- a/frontend/src/app/component/einstellungen/editieren/editieren.component.ts
+++ b/frontend/src/app/component/einstellungen/editieren/editieren.component.ts
@@ -1,6 +1,6 @@
import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
-import {FormGroup, FormBuilder} from '@angular/forms';
+import {FormGroup, FormBuilder, AbstractControl} from '@angular/forms';
import {FileInput, FileValidator} from 'ngx-material-file-input';
import {HttpClient} from '@angular/common/http';
import {environment} from '../../../../environments/environment';
@@ -9,6 +9,8 @@ import {NGXLogger} from 'ngx-logger';
import {MatSnackBar} from '@angular/material/snack-bar';
import {DialogComponent} from '../../dialog/dialog.component';
import {MatDialog} from '@angular/material/dialog';
+import {URLFormatValidator} from '../../../validators/url.validator';
+import {keywordsValidator} from '../../../validators/keywords.validator';
@Component({
selector: 'app-editieren',
@@ -44,10 +46,10 @@ export class EditierenComponent implements OnInit {
ngOnInit(): void {
this.feedForm = this.formBuilder.group({
- url: this.url,
+ url: [this.url, [URLFormatValidator]],
active: this.active,
icon: [undefined, [FileValidator.maxContentSize(this.maxSize)]],
- keywords: this.keywords,
+ keywords: [this.keywords, [keywordsValidator]],
match_all_keywords: this.match_all_keywords
});
}
diff --git a/frontend/src/app/validators/keywords.validator.ts b/frontend/src/app/validators/keywords.validator.ts
new file mode 100644
index 0000000..0166374
--- /dev/null
+++ b/frontend/src/app/validators/keywords.validator.ts
@@ -0,0 +1,6 @@
+import {AbstractControl} from '@angular/forms';
+
+export function keywordsValidator(control: AbstractControl): { [key: string]: any } | null {
+ const valid = /^((\w){3,},?){1,2}(\w{3,})?$/.test(control.value);
+ return valid ? null : {'invalidKeywords': {value: control.value}};
+}
diff --git a/frontend/src/app/validators/url.validator.ts b/frontend/src/app/validators/url.validator.ts
new file mode 100644
index 0000000..046a93c
--- /dev/null
+++ b/frontend/src/app/validators/url.validator.ts
@@ -0,0 +1,6 @@
+import {AbstractControl} from '@angular/forms';
+
+export function URLFormatValidator(control: AbstractControl): {[key: string]: any} | null {
+ const valid = /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/.test(control.value);
+ return valid ? null : {'invalidURLFormat': {value: control.value}};
+}