mirror of
https://github.com/open-reception/appointment-booking-software.git
synced 2026-08-17 21:25:52 +02:00
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
This commit is contained in:
@@ -28,11 +28,9 @@
|
||||
{@render childrenProp({ errors, errorProps })}
|
||||
{:else}
|
||||
<Text style="xs">
|
||||
<!-- {#each errors as error, index (error + index)}
|
||||
{#each errors as error, index (error + index)}
|
||||
<div {...errorProps} class={cn(errorClasses)}>{error}</div>
|
||||
{/each} -->
|
||||
|
||||
<div {...errorProps} class={cn(errorClasses)}>{errors?.[0]}</div>
|
||||
{/each}
|
||||
</Text>
|
||||
{/if}
|
||||
{/snippet}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user