• FEDSA Feed
  • Posts
  • From Input to Assertion: Practical Data Validation with Zod and Vitest

From Input to Assertion: Practical Data Validation with Zod and Vitest

FEDSA event recap & key takeaways

This article was generated with the assistance of AI to help our volunteer team share valuable insights efficiently. While we've reviewed the content for accuracy, please let us know if you spot any errors or have additional insights to contribute!

Missed our latest deep dive into Zod? You’ll want to catch up on this one.

If you’ve ever wrestled with messy form validation, inconsistent API types, or front-end/backend misalignment, this session is a game-changer. Hosted by front-end engineer Schalk Neethling, the talk walks through how Zod simplifies complex validation workflows and makes your developer experience significantly smoother — without needing to over-engineer solutions or ship unnecessary JavaScript.

Whether you’re dealing with form inputs, API payloads, or environmental variables, Zod helps you define, validate, and infer data schemas cleanly and consistently. And with the introduction of Zod v4, there’s even more power and performance packed into your favourite schema validation library.

What’s Covered in the Session

Schalk takes us through a real-world example of a dynamic form with conditional fields, optional arrays, validation rules based on user selection, and multilingual error messaging — all managed through Zod.

You’ll also learn:

  • Why Zod is great for both TypeScript and vanilla JS projects.

  • How to use Zod to share validation logic between the frontend and backend.

  • Best practices for integrating with HTML forms, including accessibility and error handling.

  • Strategies for localising error messages in multi-language applications.

  • A full walkthrough of form testing using Vitest, alongside tips on schema-driven development.

Key Takeaways

  • Runtime + Type Safety = Less Headache: Zod lets you define your validation and static typing in one place, reducing redundancy and bugs — especially in large forms or API-driven apps.

  • Use It Everywhere: Validate user input, API responses, environment variables, or even CMS content schemas. Zod isn’t just for forms — it’s for anything entering your runtime.

  • Highly Composable & Testable: Build smaller schema blocks, compose them together, and test easily with your favourite JS tools like Vitest. You’ll have more confidence in your data flow.

  • Zod 4 Boosts Performance: The latest version introduces modular builds (Zod Core/Mini), better dev/prod separation, native JSON schema conversion, and smarter error formatting — making it more production-friendly.

  • Zod vs. Other Tools: While new libraries like Valibot and Effect Schema offer interesting alternatives, Zod 4 closes many of the previous gaps and remains a strong default for modern apps.

Why You Should Watch the Full Session

This session goes far beyond the docs. You’ll see:

  • Practical demos

  • A full validation flow

  • Common pitfalls (and how to avoid them)

  • Insightful tangents about web forms, native validation, schema types, and more.

Watch the full event on YouTube and take your data validation game to the next level.

Join our Discord for discussion and updates, and subscribe to our monthly newsletter to stay in the loop.

Keen to contribute to the FEDSA community? Sign up here.

Otherwise, join our free Discord community to chat to other members!

Reply

or to participate.