# What is the "Elm Way" to validate form fields?

**URL:** <https://discourse.elm-lang.org/t/what-is-the-elm-way-to-validate-form-fields/9689>\
**Category:** Learn\
**Created:** [February 29, 2024, 8:16pm UTC](https://discourse.elm-lang.org/t/what-is-the-elm-way-to-validate-form-fields/9689 "2024-02-29T20:16:53Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![badlydrawnrob](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@badlydrawnrob](https://discourse.elm-lang.org/u/badlydrawnrob)\
**Post date:** [March 6, 2024, 5:26pm UTC](https://discourse.elm-lang.org/t/what-is-the-elm-way-to-validate-form-fields/9689/8 "2024-03-06T17:26:29Z")

</div>

@grigorious @dwayne @novid @grrinchas @ymtszw So it seems like @lydell was correct that there are lots of ways to go about form validation!!

I quite like the idea of parsing the form inputs before they reach the `type` to be stored as Elm data (either with an intermediary type, or validating inputs before they’re stored), but each of these methods could warrant their own chapter in a book!!

As with a lot of things Elm related, I know enough to see how some of the pieces work, but not enough to understand how things fit together at scale.

[Elm Spa](https://github.com/rtfeldman/elm-spa-example) is too advanced for me, although I understand bits of the form validation page — @dwayne solution does look similar to Elm’s json decoder but I’ve never used `Cmd.map` and only understand 60% of the rest.

[Elm form decoder](https://sakurachan.info/posts/2019/form-decoding/) looks like a neat solution, catching errors before they reach the `Goat` type — but that blog post is quite a lot simpler than the given Github example. There’s still a lot of question marks, such as “how do you render the specific error next it’s form field”, and more general questions about how it all fits together. I’d also be a little cautious about it’s longevity should Elm get updated.

I’m almost done with “Elm in Action” book, which goes a long way to explaining basic features in Elm, but going from that to working with package documentation and figuring out how the pieces fit together is a big problem (for me).

**So yeah, for each of these I think I’d need an “Explain it like I’m 5” blog post(s) — they’re quite complex.** A simplified, well-commented Ellie App might go a long way too 🙂

Perhaps this course on [`elm-validate`](https://frontendmasters.com/courses/advanced-elm/validated-data/) might help me understand also? I think Elm has lost a really good teacher with @rtfeldman moving to [Roc Lang](https://www.roc-lang.org/).

Thanks all!

---

_[View the full topic](https://discourse.elm-lang.org/t/what-is-the-elm-way-to-validate-form-fields/9689)._
