# Building Forms: Lesson 14 Zod Hook

**URL:** <https://forum.codewithmosh.com/t/building-forms-lesson-14-zod-hook/20918>\
**Category:** React\
**Created:** [June 19, 2023, 7:00pm UTC](https://forum.codewithmosh.com/t/building-forms-lesson-14-zod-hook/20918 "2023-06-19T19:00:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![combyses](https://avatars.discourse-cdn.com/v4/letter/c/7cd45c/32.png) [@combyses](https://forum.codewithmosh.com/u/combyses)\
**Post date:** [June 19, 2023, 7:00pm UTC](https://forum.codewithmosh.com/t/building-forms-lesson-14-zod-hook/20918/1 "2023-06-19T19:00:32Z")

</div>

The following code fragment in this lesson is not producing the results with the latest version of Zod I have installed:

```auto
const schema = z.object({
  description: z
    .string()
    .min(3, { message: "Description should be at least 3 characters" })
    .max(50),
  amount: z
    .number({ invalid_type_error: "Amount is required" })
    .min(0.01)
    .max(100_000),
  category: z.enum(categories, {
    errorMap: () => ({ message: "Category is required" }),
  }),
});

```

The “Amount is required” message shows as “Amount”.

The code that works is as follows:

```auto
const schema = z.object({
  description: z
    .string()
    .min(3, { message: "Description should be at least 3 characters" })
    .max(50),
  amount: z
    .number({
      required_error: "Amount is required",
      invalid_type_error: "Amount must be a number",
    })
    .min(0.01)
    .max(100_000),
  category: z.enum(categories, {
    errorMap: () => ({ message: "Category is required" }),
  }),
});

```

---

<div class="post-metadata">

**Author:** ![BlotCoo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/blotcoo/32/5976_2.png) [@BlotCoo](https://forum.codewithmosh.com/u/BlotCoo)\
**Post date:** [June 19, 2023, 11:08pm UTC](https://forum.codewithmosh.com/t/building-forms-lesson-14-zod-hook/20918/2 "2023-06-19T23:08:47Z")

</div>

If by ‘latest version of Zod’ you mean a version other than what Mosh is using then you’ll either have to uninstall your version of Zod and reinstall the one Mosh is using or you’ll have to go through the Zod release notes and find out what they’ve changed that breaks your code.

---

<div class="post-metadata">

**Author:** ![Brothew](https://avatars.discourse-cdn.com/v4/letter/b/898d66/32.png) [@Brothew](https://forum.codewithmosh.com/u/Brothew)\
**Post date:** [June 29, 2023, 2:39am UTC](https://forum.codewithmosh.com/t/building-forms-lesson-14-zod-hook/20918/3 "2023-06-29T02:39:29Z")

</div>

Hello,

I was running through this exact problem and actually found a fix!

Run this command in your terminal:

**npm i -save-dev @hookform/resolvers**

Source:

> <https://stackoverflow.com/questions/76399524/could-not-find-a-declaration-file-for-module-hookform-resolvers-zod>

Cheers!

Mathew
