fix(SW-360): better phone parsing in server action
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"use server"
|
||||
|
||||
import { parsePhoneNumber } from "libphonenumber-js"
|
||||
import { redirect } from "next/navigation"
|
||||
import { z } from "zod"
|
||||
|
||||
@@ -34,7 +35,9 @@ export const registerUser = serviceServerActionProcedure
|
||||
const payload = {
|
||||
...input,
|
||||
language: ctx.lang,
|
||||
phoneNumber: input.phoneNumber.replace(/\s+/g, ""),
|
||||
phoneNumber: parsePhoneNumber(input.phoneNumber)
|
||||
.formatNational()
|
||||
.replace(/\s+/g, ""),
|
||||
}
|
||||
|
||||
const parsedPayload = registerUserPayload.safeParse(payload)
|
||||
|
||||
Reference in New Issue
Block a user