Skip to content

Commit

Permalink
🐛 <InputEmail> Fix valid emails not being validated
Browse files Browse the repository at this point in the history
  • Loading branch information
gwennlbh committed Apr 24, 2023
1 parent db106a3 commit 2556bdf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib/InputEmail.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { z } from 'zod';
import BaseInputText from './BaseInputText.svelte';
import { EMAIL_REGEX } from './types';
export let id: string | undefined = undefined;
export let name: string | undefined = undefined;
Expand All @@ -10,7 +11,10 @@
export let unit: string = '';
export let suggestions: string[] | undefined = undefined;
export let required: boolean = false;
export let schema: Zod.ZodString = z.string().email({ message: 'Adresse e-mail invalide' });
export let schema: Zod.ZodString = z.string().regex(EMAIL_REGEX, {
message: 'Adresse email invalide'
}); /* don't use .email() until /~https://github.com/colinhacks/zod/pull/2224 gets merged, someone@laplace.univ-tlse.fr does not pass!!!! */
</script>

<BaseInputText
Expand Down
2 changes: 2 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ export const jsonAPIOutputsInclude = {
}
};

export const EMAIL_REGEX = /^[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~](\.?[-!#$%&'*+\/0-9=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z0-9])*\.[a-zA-Z](-?[a-zA-Z0-9])+$/;

export function createGhostEmail(
firstName: string,
lastName: string,
Expand Down

0 comments on commit 2556bdf

Please sign in to comment.