I'm very new to elm and i want to do a simple mileage counter app.
If i get "1.2"
(POINT) form input - String.toFloat
returns in the OK branch with 1.2 as a number.
But if i get "1,2"
(COMMA) form input, then String.toFloat
returns in the Err branch with "You can't have words, only numbers!"
This pretty much works like a real time validator.
The code:
TypingInInput val ->
case String.toFloat val of
Ok success ->
{ model | inputValue = val, errorMessage = Nothing }
Err err ->
{ model | inputValue = val, errorMessage = Just "You can't have words, or spaces, only numbers!" }
.
Question: So how can i force String.toFloat
of "1,2" to give me 1.2 the number?