Skip to content

Commit 35a7467

Browse files
authored
Merge pull request #183 from workfloworchestrator/2143-zod-locale
2143 zod locale
2 parents 644a016 + 90721b8 commit 35a7467

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'pydantic-forms': patch
3+
---
4+
5+
Sets locale for zod validation messages

frontend/packages/pydantic-forms/src/PydanticForm.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
*/
99
import React, { createContext } from 'react';
1010

11+
import { z } from 'zod/v4';
12+
1113
import { TranslationsProvider } from '@/messages/translationsProvider';
1214
import {
15+
Locale,
1316
PydanticFormConfig,
1417
PydanticFormProps,
1518
PydanticFormValidationErrorDetails,
@@ -31,6 +34,19 @@ export const PydanticForm = ({
3134
onSuccess,
3235
title,
3336
}: PydanticFormProps) => {
37+
const getLocale = () => {
38+
switch (config.locale) {
39+
case Locale.enGB:
40+
return z.locales.en();
41+
case Locale.nlNL:
42+
return z.locales.nl();
43+
default:
44+
return z.locales.en();
45+
}
46+
};
47+
48+
z.config(getLocale());
49+
3450
return (
3551
<TranslationsProvider
3652
customTranslations={config.customTranslations}

0 commit comments

Comments
 (0)