Don't try to parse empty phone number fields

This commit is contained in:
Saku Laesvuori 2023-10-31 18:18:31 +02:00
parent 60d8502741
commit 56c15cb7f5
Signed by: slaesvuo
GPG Key ID: 257D284A2A1D3A32
1 changed files with 1 additions and 0 deletions

View File

@ -33,6 +33,7 @@ telephoneField = Field
{ fieldParse = \rawValues _ -> { fieldParse = \rawValues _ ->
case rawValues of case rawValues of
[] -> pure $ Right Nothing [] -> pure $ Right Nothing
[""] -> pure $ Right Nothing
[x] -> pure $ maybe (Left "could not parse as a phone number") (Right . Just) $ toPhoneNumber x [x] -> pure $ maybe (Left "could not parse as a phone number") (Right . Just) $ toPhoneNumber x
_ -> pure $ Left $ "Expected one value" _ -> pure $ Left $ "Expected one value"
, fieldView = \id name otherAttributes result isRequired -> , fieldView = \id name otherAttributes result isRequired ->