Skip to content

[Bug]Error validate email #1638

@linhnvg

Description

@linhnvg
  • I use zod and react-hook-form when I validate emails but adding a dash at the end doesn't trigger the error

  • I tried using emailRegex in zod doc but no error trigger

  • I'm wondering if the problem is there or not?

  • I tried with yup and got the trigger error

import { useCallback, VFC } from "react";
import { SubmitHandler, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import * as z from "zod";

const auth = z.object({
  email: z
    .string()
    .email("正しいメールアドレスの形式で入力してください"),
  password: z.string()
});


const user = z.object({
  firstName: z
    .string()
    .min(1, { message: "1文字以上入力してください" })
    .max(10, { message: "10文字以下で入力してください" }),
  lastName: z
    .string()
    .min(1, { message: "1文字以上入力してください" })
    .max(10, { message: "10文字以下で入力してください" }),
  phoneNumber: z.string().regex(/^0\d{9,10}$/, {
    message: "正しい電話番号の形式で入力してください"
  }),
  role: z.enum(["admin", "user"])
});

image

image

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions