Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Possibly stupid question, but why does the dog array validate:

  const dogsList = z.array(dogSchema);

  dogSchema.parse([
   { name: 'Cujo', neutered: null },
   { name: 'Fido', age: 4, neutered: true },
  ]); // passes
Since 'Cujo' doesn't have an age? Assuming it's the same dogSchema as in the previous block, age is required, right?

Oh, and a minor typo: This lets you confidently This way you can confidently....



Ah I see I misread your comment.

You're right, Cujo also shouldn't have validated. In a previous version of the post `neutered` was nullable and `age` was optional, but I decided to save the discussion of nullables/optional until later so I changed it. Good catch!!


Whoops! Should be `dogsList.parse(...)`.

Also fixed the other typo :)

Thanks!!


I don’t want to derail the thread, but just a heads up: the layout is very broken on my phone (iPhone). The text is clipped on the left side which basically makes the article unreadable!


Consider the thread derailed :P

Just fixed this! I'd done exactly zero testing on mobile (built the site from scratch yesterday).


Haha! Timed that well didn’t we...


Sorry to be a pain but even a few rules (even resetting some things) would make it much easier to read on mobile!


Fixed! I'd done exactly zero testing on mobile (built the site from scratch yesterday).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: