-
Hi @amannn, I'm trying to execute the https://next-safe-action.dev/docs/recipes/i18n recipes, for that I need to access the T function type to get proper DX. Note After some experimentation, I have succeeded in extracting the typings correctly. Maybe we could add this to the documentation. type TFn =
| ReturnType<typeof useTranslations<never>>
| Awaited<ReturnType<typeof getTranslations<never>>>;
export const authSchema = (t: TFn) => {
return z.object({
username: z.string(),
password: z.string(),
resellerCode: z.coerce.number(),
});
}; import { getTranslations } from "next-intl/server";
export async function MyPage {
const t = await getTranslations()
const schema = authSchema()
} export const AuthenticationForm = () => {
const t = useTranslations();
const schema = authSchema(t);
} |
Beta Was this translation helpful? Give feedback.
Answered by
amannn
Sep 17, 2024
Replies: 1 comment 2 replies
-
@amannn Any thoughts on adding that to the documentation? I might submit a pull request |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @ScreamZ!
It's really kind of you to offer a pull request, but as discussed in #1134, the snippet that's shown in the
next-safe-action
docs is unfortunately not what I'd recommend.There's now a basic
zod
example in the docs. As fornext-safe-action
, I think trying outhandleValidationErrorsShape
could be something to look into (and if this works, maybe a PR to thenext-safe-action
docs could be helpful).