import { z } from 'zod' import { contactPhoneField, languageSchema, localizedTextIssue, validateLocalizedText } from '../../lib/zodValidation' export const renterUpdateSchema = z.object({ firstName: z.string().trim().max(50).transform((value) => value.normalize('NFC')).optional(), lastName: z.string().trim().max(50).transform((value) => value.normalize('NFC')).optional(), phone: contactPhoneField().optional(), preferredLocale: languageSchema.optional(), preferredCurrency: z.literal('MAD').optional(), }).superRefine((data, ctx) => { const language = data.preferredLocale ?? 'fr' if (data.firstName && !validateLocalizedText(data.firstName, language, 50)) { ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['firstName'], message: localizedTextIssue('First name') }) } if (data.lastName && !validateLocalizedText(data.lastName, language, 50)) { ctx.addIssue({ code: z.ZodIssueCode.custom, path: ['lastName'], message: localizedTextIssue('Last name') }) } }) export const renterFcmTokenSchema = z.object({ fcmToken: z.string(), })