Skip to content

Commit

Permalink
Merge pull request #1843 from abizek/fix/tfa-length-error-message
Browse files Browse the repository at this point in the history
Fix(tfa): error message for tfa code length
  • Loading branch information
AmruthPillai committed May 20, 2024
2 parents a598a7a + e24f885 commit 868e6de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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()),
});

Expand Down
5 changes: 4 additions & 1 deletion libs/dto/src/auth/two-factor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down

0 comments on commit 868e6de

Please sign in to comment.