upped cookie length from 30 seconds to 10 minutes added default values to prevent the default required error message to appear in form
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import { defineMessage } from "react-intl"
|
|
import { z } from "zod"
|
|
|
|
export {
|
|
type AdditionalInfoFormSchema,
|
|
additionalInfoFormSchema,
|
|
type FindMyBookingFormSchema,
|
|
findMyBookingFormSchema,
|
|
}
|
|
|
|
defineMessage({
|
|
id: "Invalid booking number",
|
|
})
|
|
defineMessage({
|
|
id: "Booking number is required",
|
|
})
|
|
defineMessage({
|
|
id: "First name is required",
|
|
})
|
|
defineMessage({
|
|
id: "Last name is required",
|
|
})
|
|
defineMessage({
|
|
id: "Email address is required",
|
|
})
|
|
|
|
const additionalInfoFormSchema = z.object({
|
|
firstName: z.string().trim().max(250).min(1, {
|
|
message: "First name is required",
|
|
}),
|
|
email: z.string().max(250).email({ message: "Email address is required" }),
|
|
})
|
|
|
|
const findMyBookingFormSchema = additionalInfoFormSchema.extend({
|
|
confirmationNumber: z
|
|
.string()
|
|
.trim()
|
|
.min(1, {
|
|
message: "Booking number is required",
|
|
})
|
|
.regex(/^[0-9]+(-[0-9])?$/, {
|
|
message: "Invalid booking number",
|
|
}),
|
|
lastName: z.string().trim().max(250).min(1, {
|
|
message: "Last name is required",
|
|
}),
|
|
})
|
|
|
|
type AdditionalInfoFormSchema = z.output<typeof additionalInfoFormSchema>
|
|
|
|
type FindMyBookingFormSchema = z.output<typeof findMyBookingFormSchema>
|