Live validation

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 to perform validations on it, and my update is quite “complex” already because the model is nested

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


Hi @ngw

perhaps this a package elm-validate may help you, also see link on demo at readme…

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