From b59b43fcfaae3a7a37450873429442faf3c27269 Mon Sep 17 00:00:00 2001 From: RaafatDev Date: Fri, 3 Jul 2026 11:45:06 +0200 Subject: [PATCH 1/2] #289 fixed a bug in form-field-errors.svelte to prevent displaying multiple errors at the same time and duplicate errors with the same index which caused break form submit in settings page --- src/lib/components/ui/form/form-field-errors.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/components/ui/form/form-field-errors.svelte b/src/lib/components/ui/form/form-field-errors.svelte index 59b8770..1acf81e 100644 --- a/src/lib/components/ui/form/form-field-errors.svelte +++ b/src/lib/components/ui/form/form-field-errors.svelte @@ -28,9 +28,11 @@ {@render childrenProp({ errors, errorProps })} {:else} - {#each errors as error (error)} + + +
{errors?.[0]}
{/if} {/snippet} From 5b4c7816eb01365e308efb45f0613e3ae3d03911 Mon Sep 17 00:00:00 2001 From: RaafatDev Date: Fri, 3 Jul 2026 15:41:40 +0200 Subject: [PATCH 2/2] #289 1. reactivated the display of multiple validation-error in form-field-errors.svelte 2. fixed a bug in settings-schema that caused duplicate validation-error to be triggered when the URLs are invalid --- .../ui/form/form-field-errors.svelte | 6 ++--- .../(components)/edit-settings-form/schema.ts | 23 +++++++++++++++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/lib/components/ui/form/form-field-errors.svelte b/src/lib/components/ui/form/form-field-errors.svelte index 1acf81e..8fb4b1b 100644 --- a/src/lib/components/ui/form/form-field-errors.svelte +++ b/src/lib/components/ui/form/form-field-errors.svelte @@ -28,11 +28,9 @@ {@render childrenProp({ errors, errorProps })} {:else} - - -
{errors?.[0]}
+ {/each}
{/if} {/snippet} diff --git a/src/routes/(pages)/dashboard/settings/(components)/edit-settings-form/schema.ts b/src/routes/(pages)/dashboard/settings/(components)/edit-settings-form/schema.ts index 58458f9..604332b 100644 --- a/src/routes/(pages)/dashboard/settings/(components)/edit-settings-form/schema.ts +++ b/src/routes/(pages)/dashboard/settings/(components)/edit-settings-form/schema.ts @@ -5,11 +5,24 @@ const optionalUrl = (errorMessage: string) => z .union([ z.literal(""), - z - .url({ message: errorMessage }) - .refine((url) => url.startsWith("http://") || url.startsWith("https://"), { - message: errorMessage, - }), + // z + // .url({ message: errorMessage }) + // .refine((url) => url.startsWith("http://") || url.startsWith("https://"), { + // message: errorMessage, + // }), + z.string().refine( + (val) => { + try { + // 1. Check if it's a valid URL structure + const url = new URL(val); + // 2. Check if it uses the correct HTTP protocols + return url.protocol === "http:" || url.protocol === "https:"; + } catch { + return false; // Fails if not a valid URL structure + } + }, + { message: errorMessage }, + ), ]) .optional();