# Live validation

**URL:** <https://discourse.elm-lang.org/t/live-validation/2341>\
**Category:** Learn\
**Created:** [October 28, 2018, 4:06pm UTC](https://discourse.elm-lang.org/t/live-validation/2341 "2018-10-28T16:06:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ngw](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/ngw/32/205_2.png) [@ngw](https://discourse.elm-lang.org/u/ngw)\
**Post date:** [October 28, 2018, 4:06pm UTC](https://discourse.elm-lang.org/t/live-validation/2341/1 "2018-10-28T16:06:01Z")

</div>

I’m working on yet another form, and I need live validation.  
Right now I’ve added validation to onBlur, but of course this is quite suboptimal because when I update the fields that didn’t pass validation the error message is still there until I trigger onBlur again.  
On the other hand I don’t want to use onInput because I don’t want my inputs to be validated every time the content is changed.  
I thought about keeping some kind of state inside the field but that looks rather custom and complicated, onBlur I should set a bool to true then validate onInput I guess.

My type is quite simple:

```
type alias Password =
  { value : String
  , error : String
  , visible : Bool
  }

```

I’m using [rtfeldman/elm-validate](https://package.elm-lang.org/packages/rtfeldman/elm-validate/latest/) to perform validations on it, and my update is quite “complex” already because the model is nested

> <https://gist.github.com/ngw/8cdd695decab84bdddbfbe795a5dbac8>

I’d need to add a lot of empty the errors/refill the errors and I doubt that would result in very nice code.  
I’ve tried to use elm-form in the past, but since 0.19 it crashes for some reasons with the Map.! error - most probably because I’m nesting messages in my update, so that’s not really an option.  
How do you people solve this problem? Debouncers?

TIA, ngw

---

<div class="post-metadata">

**Author:** ![ondrej-tucek](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/ondrej-tucek/32/1451_2.png) [@ondrej-tucek](https://discourse.elm-lang.org/u/ondrej-tucek)\
**Post date:** [October 28, 2018, 7:37pm UTC](https://discourse.elm-lang.org/t/live-validation/2341/2 "2018-10-28T19:37:09Z")

</div>

Hi @ngw

perhaps this a package [elm-validate](https://github.com/iodevs/elm-validate) may help you, also see link on demo at readme…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [November 7, 2018, 7:37pm UTC](https://discourse.elm-lang.org/t/live-validation/2341/3 "2018-11-07T19:37:16Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
