Merge pull request #1843 from abizek/fix/tfa-length-error-message

Fix(tfa): error message for tfa code length
This commit is contained in:
Amruth Pillai
2024-05-20 16:36:23 +02:00
committed by GitHub
2 changed files with 9 additions and 4 deletions
@@ -1,5 +1,6 @@
import { zodResolver } from "@hookform/resolvers/zod";
import { t } from "@lingui/macro";
import { i18n } from "@lingui/core";
import { msg, t } from "@lingui/macro";
import { QrCode } from "@phosphor-icons/react";
import {
Alert,
@@ -46,8 +47,9 @@ import { useDialog } from "@/client/stores/dialog";
const formSchema = z.object({
uri: z.literal("").or(z.string().optional()),
// eslint-disable-next-line lingui/t-call-in-function
code: z.literal("").or(z.string().regex(/^\d{6}$/, t`Code must be exactly 6 digits long.`)),
code: z
.literal("")
.or(z.string().regex(/^\d{6}$/, i18n._(msg`Code must be exactly 6 digits long.`))),
backupCodes: z.array(z.string()),
});
+4 -1
View File
@@ -2,7 +2,10 @@ import { createZodDto } from "nestjs-zod/dto";
import { z } from "nestjs-zod/z";
export const twoFactorSchema = z.object({
code: z.string().length(6).regex(/^\d+$/, { message: "code must be a 6 digit number" }),
code: z
.string()
.length(6, { message: "Code must be a 6 digit number" })
.regex(/^\d+$/, { message: "Code must be a 6 digit number" }),
});
export class TwoFactorDto extends createZodDto(twoFactorSchema) {}