wip
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
// Shared between the customer reservation form (lib/reservations.ts) and the
|
||||
// staff phone field (routes/staff.team.tsx), so "a valid phone number" means
|
||||
// the same thing everywhere in the app.
|
||||
export const phoneSchema = z
|
||||
.string()
|
||||
.trim()
|
||||
.max(30, 'Enter a valid phone number')
|
||||
// Optional leading `+` plus digits and common separators (spaces, dashes,
|
||||
// dots, parentheses) — permissive about international formats, but the
|
||||
// character class alone would still accept e.g. "()---" or "+", so the
|
||||
// refine below requires it to actually contain a real number of digits.
|
||||
.regex(/^\+?[0-9()\-.\s]+$/, 'Enter a valid phone number')
|
||||
.refine((value) => (value.match(/\d/g)?.length ?? 0) >= 6, 'Enter a valid phone number')
|
||||
Reference in New Issue
Block a user