fix: replace enter details first-/lastname regex

This commit is contained in:
Arvid Norlin
2024-12-09 15:15:39 +01:00
parent 80f7e8e7f8
commit a5a99c1432

View File

@@ -2,7 +2,8 @@ import { z } from "zod"
import { phoneValidator } from "@/utils/phoneValidator" import { phoneValidator } from "@/utils/phoneValidator"
const stringMatcher = /^[\p{L}\s\-\.]+$/u const stringMatcher =
/^[A-Za-z¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0-9-\s]*$/
const isValidString = (key: string) => stringMatcher.test(key) const isValidString = (key: string) => stringMatcher.test(key)
@@ -13,13 +14,13 @@ export const baseDetailsSchema = z.object({
.string() .string()
.min(1, { message: "First name is required" }) .min(1, { message: "First name is required" })
.refine(isValidString, { .refine(isValidString, {
message: "First name can't contain any special charachters", message: "First name can't contain any special characters",
}), }),
lastName: z lastName: z
.string() .string()
.min(1, { message: "Last name is required" }) .min(1, { message: "Last name is required" })
.refine(isValidString, { .refine(isValidString, {
message: "Last name can't contain any special charachters", message: "Last name can't contain any special characters",
}), }),
phoneNumber: phoneValidator(), phoneNumber: phoneValidator(),
}) })