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