From 50da90b0ef878dbb77f9ae1a7c4f43d775425cd8 Mon Sep 17 00:00:00 2001 From: Adrian Andersen Date: Mon, 19 Aug 2024 12:08:25 +0200 Subject: [PATCH] fix(UserDetailEditor): enforce full name --- src/components/user/user-detail-editor/YourInfoSection.tsx | 2 +- src/components/user/user-detail-editor/fieldValidators.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/user/user-detail-editor/YourInfoSection.tsx b/src/components/user/user-detail-editor/YourInfoSection.tsx index 8093bdd..b71e90e 100644 --- a/src/components/user/user-detail-editor/YourInfoSection.tsx +++ b/src/components/user/user-detail-editor/YourInfoSection.tsx @@ -48,7 +48,7 @@ const YourInfoSection = ({ autoComplete="name" fullWidth id="name" - label="Navn" + label="Fullt navn" error={!!errors.name} {...register("name", fieldValidators.name)} /> diff --git a/src/components/user/user-detail-editor/fieldValidators.ts b/src/components/user/user-detail-editor/fieldValidators.ts index 053851c..03f2345 100644 --- a/src/components/user/user-detail-editor/fieldValidators.ts +++ b/src/components/user/user-detail-editor/fieldValidators.ts @@ -23,7 +23,11 @@ export const fieldValidators: { }, }, name: { - required: "Du må fylle inn navn", + required: "Du må fylle inn ditt fulle navn", + validate: (v: string) => + v.split(" ").length > 1 + ? true + : "Du må fylle inn både fornavn og etternavn", }, phoneNumber: { required: "Du må fylle inn telefonnummer",