* feat: blocklist table * feat: blocklist table * refactor: feedback * chore: add select * UI improvements * chore: remove un unsed --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com>
27 lines
958 B
TypeScript
27 lines
958 B
TypeScript
import { z } from "zod";
|
|
|
|
/** @see https://github.com/colinhacks/zod/issues/3155#issuecomment-2060045794 */
|
|
export const emailRegex =
|
|
/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.']*)[A-Z0-9_+'-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
|
|
/**
|
|
* Domain regex for watchlist entries - requires @ prefix
|
|
* Supports international domains with Unicode characters
|
|
* Examples: @example.com, @münchen.de, @example.co.uk
|
|
*/
|
|
export const domainWithAtRegex =
|
|
/^@[a-zA-Z0-9\u00a1-\uffff]([a-zA-Z0-9\u00a1-\uffff-]*[a-zA-Z0-9\u00a1-\uffff])?(\.[a-zA-Z0-9\u00a1-\uffff]([a-zA-Z0-9\u00a1-\uffff-]*[a-zA-Z0-9\u00a1-\uffff])?)*$/;
|
|
|
|
/**
|
|
* RFC 5321 Section 4.5.3.1.3 specifies:
|
|
* - Maximum email address length: 254 characters
|
|
* - Local part (before @): max 64 characters
|
|
* - Domain part (after @): max 253 characters
|
|
*/
|
|
const MAX_EMAIL_LENGTH = 254;
|
|
|
|
export const emailSchema = z
|
|
.string()
|
|
.max(MAX_EMAIL_LENGTH, { message: "Email address is too long" })
|
|
.regex(emailRegex);
|