feat: pass specialRequest.comment to create booking * feat: pass specialRequest.comment to create booking Approved-by: Simon.Emanuelsson
46 lines
1.5 KiB
TypeScript
46 lines
1.5 KiB
TypeScript
import { z } from "zod"
|
|
|
|
import { specialRequestSchema } from "@/components/HotelReservation/EnterDetails/Details/SpecialRequests/schema"
|
|
import { phoneValidator } from "@/utils/zod/phoneValidator"
|
|
|
|
// stringMatcher regex is copied from current web as specified by requirements.
|
|
const stringMatcher =
|
|
/^[A-Za-z¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0-9-\s]*$/
|
|
|
|
const isValidString = (key: string) => stringMatcher.test(key)
|
|
|
|
export const multiroomDetailsSchema = z.object({
|
|
countryCode: z.string().min(1, { message: "Country is required" }),
|
|
email: z.string().email({ message: "Email address is required" }),
|
|
firstName: z
|
|
.string()
|
|
.min(1, { message: "First name is required" })
|
|
.refine(isValidString, {
|
|
message: "First name can't contain any special characters",
|
|
}),
|
|
join: z.boolean().default(false),
|
|
lastName: z
|
|
.string()
|
|
.min(1, { message: "Last name is required" })
|
|
.refine(isValidString, {
|
|
message: "Last name can't contain any special characters",
|
|
}),
|
|
phoneNumber: phoneValidator(),
|
|
membershipNo: z
|
|
.string()
|
|
.optional()
|
|
.refine((val) => {
|
|
if (val) {
|
|
return !val.match(/[^0-9]/g)
|
|
}
|
|
return true
|
|
}, "Only digits are allowed")
|
|
.refine((num) => {
|
|
if (num) {
|
|
return num.match(/^30812(?!(0|1|2))[0-9]{9}$/)
|
|
}
|
|
return true
|
|
}, "Invalid membership number format"),
|
|
specialRequest: specialRequestSchema,
|
|
})
|