Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find regex on z.string #81

Open
netgfx opened this issue May 13, 2024 · 2 comments
Open

Can't find regex on z.string #81

netgfx opened this issue May 13, 2024 · 2 comments

Comments

@netgfx
Copy link

netgfx commented May 13, 2024

I get Property 'regex' does not exist on type 'ZodEffects<ZodString, string, string>'

I define the z.strng like this:

z.string({
        required_error: 'Username is required',
        invalid_type_error: 'Name must be a string',
      })
      .refine(
        (data: string) => data.length > 0,
        (val: string) => ({
          message: 'Username cannot be empty',
        }),
      )
      .regex(/^[a-zA-Z0-9]+$/, {
        message: 'Username can only contain alphanumeric characters',
      })
      .min(3, {message: 'Username must be at least 3 characters long'})
      .max(20, {message: 'Username cannot exceed 20 characters'})

Could this be because the zod version of the library is outdated? Locally I have zod version 3.23.8

@kibertoad
Copy link
Collaborator

might be. I'll try to release the updated version this week

@kibertoad
Copy link
Collaborator

Can you please try 1.2.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants