feat(phone-input): integrate phone number input component and validation

- Added `libphonenumber-js` dependency for improved phone number handling.
- Refactored `CreateAdmin` form to utilize a new `PhoneNumberInput` component with validation rules.
- Updated `useCreateAdminPresenter` to normalize phone number input before submission.
- Enhanced error messages for phone validation in `Texts` constant.
- Modified `User` schema to validate phone numbers using E.164 format.
This commit is contained in:
AmirReza Jamali
2026-05-16 10:28:03 +03:30
parent f79348312b
commit d9a945904a
11 changed files with 378 additions and 25 deletions
+8 -1
View File
@@ -1,3 +1,4 @@
import { isValidE164Phone } from "@/lib/phone/e164";
import { z } from "zod";
import { createApiResponseSchema } from "./Factory";
@@ -25,7 +26,13 @@ export const UserSchema = z.object({
export const CreateAdminSchema = z.object({
full_name: z.string().min(1, "Full name is required"),
email: z.string().email("Invalid email address"),
phone: z.string().regex(/^\+?[1-9]\d{1,14}$/, "Invalid phone number"),
phone: z
.string()
.optional()
.transform((val) => (val?.trim() ? val.trim() : ""))
.refine((val) => !val || isValidE164Phone(val), {
message: "Invalid phone number",
}),
password: z
.string()
.min(8, "Password must be at least 8 characters long")