zod Questions

4

I have to use the react-password-checklist library to show the user if he is obeying the password rules declared in zod's schemaUser. However, I am not successful. obs: I'm using zod to validate th...
Scape asked 11/8, 2023 at 19:14

2

Solved

If I had a property that should be limited to only a few possible values, using Yup I could do something like: prop: Yup.string().oneOf([5, 10, 15]) I can not seem to find something similar in Zod...
Nigeria asked 26/12, 2022 at 14:56

10

I am having an issue with Shadcn react library's Select component. It seems that "dynamically" generated SelectItem is causing an issue were they are not displayed in the SelectValue box ...
Sinistrodextral asked 6/9, 2023 at 9:41

3

I am not able to read the select value in shadcn form Select. I am using serveraction. So, I am creating a form to send emails, i am able to read the values of other fields but not the value for Se...
Silberman asked 4/12, 2023 at 7:20

2

I desperately tried to generate a zod schema dynamically without success. I have coded a kind of reusable form with react-hook-form, allowing me to easily create forms with various number of inputs...
Underpass asked 11/4, 2023 at 9:9

2

Solved

I have an email input and i want to validate that the user entered a specific email "[email protected]" and if not to show specific error message "This email is not in our datab...
Taxable asked 17/1, 2023 at 14:56

5

Solved

I have an endpoint that should get a parameter method which should comply with the Axios type Method. How can I create a schema with Zod that validates that the value is using the type Schema? impo...
Subbase asked 7/4, 2022 at 12:55

2

Solved

I'm trying to create a dictionary like zod schema for an object that has many keys, defined elsewhere, and they all have the same value type. And all keys are required. const KeysSchema = z.enum(['...
Hooded asked 7/2, 2024 at 23:21

5

I am new to using zod for valiadtion. I have read through the documentation but I can see anything on how to add a validation for a phone number. I used the email one to make sure a user enters a c...
zod
Cavallaro asked 25/10, 2022 at 11:4

6

Solved

I have a field where I want the value to either be optional OR have the field have a minimum length of 4. I've tried the following: export const SocialsSchema = z.object({ myField: z.optional(z.st...
Arthrospore asked 2/9, 2022 at 12:0

3

Solved

I've 3 schema for a blog post. Image post Video post Text post Schema look like this // will be used for form validation // text can be added but image required const imagePostSchema = z.object(...
Intolerable asked 5/11, 2023 at 20:13

3

Solved

Is it possible to define a Zod schema with a field that is possibly undefined, but non-optional. In TypeScript this is the difference between: interface IFoo1 { somefield: string | undefined; } i...
Steel asked 15/3, 2022 at 4:18

4

Solved

I'm pretty sure this exists, but I haven't been able to find anything about it despite some digging. Say that I have a zod Schema like such: const Person = zod.object({ name: z.string().default(''...
Nogging asked 27/6, 2022 at 7:9

2

I was trying to chain multiple regex expressions for a single input field. Although it checked for every regex expression but only the error message for the first regex expression was being display...
Hotien asked 20/2, 2023 at 15:10

4

How do I check for confirm password with zod?. I want to validate for confirm password with Zod. I want Zod to compare my password with comparePassword export const registerUSerSchema = z.object({ ...
Structuralism asked 12/9, 2022 at 21:42

2

Solved

a little background Im using shadcn ui library and Zod to create some simple forms in my Next.js React app. The input are of type select and text The problem I'm following shadcn documentation on h...
Hufuf asked 29/9, 2023 at 12:7

2

I am looking for a way of translating Zod error messages when using the next-intl package. Perhaps an alternative to Zod-i18n, instead of i18next. The reasons for picking next-intl instead of...
Windbreak asked 26/10, 2023 at 13:1

3

I'm using material ui components with react-hook-form and zod validation. I have a bloodType select field: const bloodTypes = [ "A+", "A-", "B+", "B-", &quot...
Moonstone asked 25/5, 2023 at 4:20

2

I'm using the zod library to validate a form in my Next.js application. I've defined a schema for a subscription form that should validate an email field. I want to display a custom error message -...
Dogtooth asked 16/9, 2023 at 13:39

3

Solved

I have this object: const properties = [ { value: "entire_place", label: "The entire place" }, { value: "private_room", label: "A private room" }, { value...
Jerold asked 23/9, 2022 at 8:53

5

I use input type="file" and instead of saving data in FileData I use just plain object and created a type for it: Record<string, File>. It works well, but when I try to create a val...
Glyptic asked 20/12, 2021 at 11:20

5

Solved

I have created a form with react hook form and did a validation with zod. In one input I want to write in numbers, when I write any number, the error says it is not a number: <Controller name=&...
Representative asked 10/8, 2023 at 19:3

2

Solved

I'm trying to write a custom error message for zod validation. This is my schema object, which I passed in the error message. const schema: ZodType<FormData> = z.object({ firstName: z.string...
Midweek asked 30/3, 2023 at 0:0

6

I have a problem, I need to validate an image with zod. I am searching for 3 hours. I can't find out on validating the image? Can anyone help me out to fix this? zod must have image validate yes? c...
Acidic asked 19/6, 2022 at 7:13

4

Solved

I have this Type export type PaymentType = 'CHECK' | 'DIRECT DEPOSIT' | 'MONEY ORDER'; I want to validate this literal string type in zod. Currently, I have is as a string, but that wrong is not a...
Colemancolemanite asked 1/2, 2023 at 23:25

© 2022 - 2025 — McMap. All rights reserved.