Skip to content

Commit

Permalink
fix: form phone not required (#897)
Browse files Browse the repository at this point in the history
  • Loading branch information
OverGlass authored Oct 28, 2024
1 parent 7c322a1 commit ef10c4b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/features/profil/pages/account/form/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ export const validateInformationsFormSchema = z.object({
export const validateCoordFormSchema = z.object({
phone: z
.object({
country: z.string(buildReqError('Le code pays')).refine((x) => getCountryCodeForRegionCode(x) !== undefined, {
message: 'Le code pays doit être de deux lettres',
}),
number: requiredString('Le numéro de téléphone'),
country: z
.string(buildReqError('Le code pays'))
.refine((x) => getCountryCodeForRegionCode(x) !== undefined, {
message: 'Le code pays doit être de deux lettres',
})
.optional(),
number: z.string().optional(),
})
.refine(
({ country, number }) => {
if (!number) return true
return parsePhoneNumber(number, { regionCode: country }).valid
},
{
message: 'Le numéro de téléphone n’est pas valide',
message: 'Numéro invalide',
},
),
email_address: z.string().email('L’adresse email n’est pas valide'),
Expand Down

0 comments on commit ef10c4b

Please sign in to comment.