-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trekker komponenter ut i egne filer
- Loading branch information
Showing
4 changed files
with
35 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {FieldError} from "react-hook-form"; | ||
import {useTranslation} from "react-i18next"; | ||
import {DigisosLanguageKey} from "../i18n/common.ts"; | ||
import * as React from "react"; | ||
|
||
export const TranslatedError = ({error}: {error: Pick<FieldError, "message">}) => { | ||
const {t} = useTranslation("skjema"); | ||
|
||
if (!error?.message) return null; | ||
|
||
return <>{t(error.message as DigisosLanguageKey)}</>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as z from "zod"; | ||
import {DigisosLanguageKey} from "../../lib/i18n/common.ts"; | ||
|
||
export const MAX_LEN_HVA = 500; | ||
export const MAX_LEN_HVORFOR = 600; | ||
const feilmeldinger: Record<string, DigisosLanguageKey> = { | ||
maksLengde: "validering.maksLengde", | ||
} as const; | ||
|
||
export interface FormValues { | ||
hvaSokesOm?: string | null; | ||
hvorforSoke?: string | null; | ||
} | ||
|
||
export const begrunnelseSchema = z.object({ | ||
hvaSokesOm: z.string().max(MAX_LEN_HVA, feilmeldinger.maksLengde).optional(), | ||
hvorforSoke: z.string().max(MAX_LEN_HVORFOR, feilmeldinger.maksLengde), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters