Files
emaui/libs/ui/src/lib/input/phone.ts
estifanos 85c9930363 Add address management features and improve validation
- Implement saveMyAddress mutation for updating user addresses.
- Enhance address validation schema with additional fields.
- Add error handling for location loading in LocationPicker.
- Update translations for loading errors in English and Amharic.
- Introduce phone number validation for Ethiopian formats.
- Refactor AddressFormContent to accommodate new address structure.
2026-08-08 07:32:33 +00:00

14 lines
470 B
TypeScript

import { z } from 'zod';
/** Accepts `09xxxxxxxx` or `+2519xxxxxxxx`; always yields `+2519xxxxxxxx`. */
export const ethiopianPhone = z
.string()
.trim()
.transform((v) => (/^09\d{8}$/.test(v) ? `+251${v.slice(1)}` : v))
.refine((v) => /^\+2519\d{8}$/.test(v), {
message: 'Enter a valid phone number (+2519xxxxxxxx)',
});
/** Same rules, but blank is allowed. */
export const optionalEthiopianPhone = z.union([z.literal(''), ethiopianPhone]).optional();