mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-01 07:45:22 +03:00
Show required error message for missing required number field.
This commit is contained in:
parent
b82aa41416
commit
b7d58471f9
13
src/Form.elm
13
src/Form.elm
@ -640,10 +640,15 @@ requiredNumber name toHtmlFn =
|
|||||||
toHtmlFn (toInputRecord name Nothing info fieldInfo)
|
toHtmlFn (toInputRecord name Nothing info fieldInfo)
|
||||||
, decode =
|
, decode =
|
||||||
\rawString ->
|
\rawString ->
|
||||||
rawString
|
case rawString of
|
||||||
|> Maybe.andThen String.toInt
|
Nothing ->
|
||||||
-- TODO should this be a custom type instead of String error? That way users can customize the error messages
|
Err "This field is required"
|
||||||
|> Result.fromMaybe "Not a valid number"
|
|
||||||
|
Just string ->
|
||||||
|
string
|
||||||
|
|> String.toInt
|
||||||
|
-- TODO should this be a custom type instead of String error? That way users can customize the error messages
|
||||||
|
|> Result.fromMaybe "Not a valid number"
|
||||||
, properties = []
|
, properties = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user