Show required error message for missing required number field.

This commit is contained in:
Dillon Kearns 2022-01-10 11:43:51 -08:00
parent b82aa41416
commit b7d58471f9

View File

@ -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 = []
} }