mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
Set email field optional in passenger information
This commit is contained in:
@@ -568,9 +568,8 @@ function createFormSchema(adultCount: number) {
|
||||
// Contact fields are only collected from — and validated against — adults.
|
||||
// Children's phone/email are inherited from the primary adult, not user-entered.
|
||||
if (isAdult) {
|
||||
if (!p.email || p.email.trim().length === 0) {
|
||||
ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Email is required', path: ['passengers', i, 'email'] });
|
||||
} else {
|
||||
// Email is optional — only validate its format when the user actually provides one.
|
||||
if (p.email && p.email.trim().length > 0) {
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
if (!emailRegex.test(p.email)) {
|
||||
ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Invalid email format', path: ['passengers', i, 'email'] });
|
||||
@@ -1191,7 +1190,7 @@ export default function PassengersPage() {
|
||||
|
||||
{/* Email */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium mb-1 text-gray-700 dark:text-gray-300">Email *</label>
|
||||
<label className="block text-sm font-medium mb-1 text-gray-700 dark:text-gray-300">Email (optional)</label>
|
||||
<input
|
||||
type="email"
|
||||
{...register(`passengers.${index}.email`)}
|
||||
@@ -1280,7 +1279,7 @@ export default function PassengersPage() {
|
||||
|
||||
{/* Email */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium mb-1 text-gray-700 dark:text-gray-300">Email *</label>
|
||||
<label className="block text-sm font-medium mb-1 text-gray-700 dark:text-gray-300">Email (optional)</label>
|
||||
<input
|
||||
type="email"
|
||||
{...register(`passengers.${index}.email`)}
|
||||
|
||||
Reference in New Issue
Block a user