Update libphonenumber-js

This commit is contained in:
Anton Gunnarsson
2025-05-06 16:22:37 +02:00
parent 3110f9aec2
commit 41aa4f26ad
5 changed files with 18 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
import {
isPossiblePhoneNumber,
ParseError,
parsePhoneNumber,
parsePhoneNumberWithError,
validatePhoneNumberLength,
} from "libphonenumber-js"
import { z } from "zod"
@@ -24,7 +24,7 @@ export function phoneValidator(
.superRefine((value, ctx) => {
if (value) {
try {
const phoneNumber = parsePhoneNumber(value)
const phoneNumber = parsePhoneNumberWithError(value)
if (phoneNumber) {
if (isPossiblePhoneNumber(value, phoneNumber.country)) {
return validatePhoneNumberLength(value, phoneNumber.country)