mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-29 19:58:13 +00:00
- 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.
14 lines
470 B
TypeScript
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();
|