From f839706d05d0c5052c19569a7f1e2bc5333f4436 Mon Sep 17 00:00:00 2001 From: Toast Date: Thu, 6 Feb 2025 18:45:45 +0100 Subject: [PATCH] Components/create-edit-modal: add validation to image controls --- .../create-edit-modal/create-edit-modal.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/create-edit-modal/create-edit-modal.component.ts b/src/components/create-edit-modal/create-edit-modal.component.ts index 87bec2c..b00c501 100644 --- a/src/components/create-edit-modal/create-edit-modal.component.ts +++ b/src/components/create-edit-modal/create-edit-modal.component.ts @@ -55,7 +55,8 @@ export class CreateEditModalComponent { } protected addImageControl() { - this.images.push(new FormControl("")) + const urlRegex: string = '(https?://)?([\\da-z.-]+)\\.([a-z.]{2,6})[/\\w .-]*/?' + this.images.push(new FormControl("", [Validators.required, Validators.pattern(urlRegex)])) } protected removeImageControl(index: number) {