Verify email format more strictly
This commit is contained in:
parent
7983f9b187
commit
28af340573
|
@ -101,7 +101,8 @@ renderPhoneNumber (PhoneNumber txt) = txt
|
|||
toPhoneNumber :: Text -> Maybe PhoneNumber
|
||||
toPhoneNumber txt = do
|
||||
guard $ not $ T.null txt
|
||||
guard $ T.all (`elem` ("+ 0123456789" :: [Char])) txt
|
||||
guard $ T.head txt `elem` ['+','0']
|
||||
guard $ T.all (`elem` (" 0123456789" :: [Char])) $ T.tail txt
|
||||
pure $ PhoneNumber txt
|
||||
|
||||
instance Eq PhoneNumber where
|
||||
|
|
|
@ -39,7 +39,7 @@ telephoneField = Field
|
|||
, fieldView = \id name otherAttributes result isRequired ->
|
||||
let result' = either (\x -> x) renderPhoneNumber result
|
||||
in [whamlet|
|
||||
<input type="tel" id="#{id}" name="#{name}" value="#{result'}" pattern="[+ 0123456789]*" title="Only '+', spaces and numbers are allowed" "*{otherAttributes} :isRequired:required="true">
|
||||
<input type="tel" id="#{id}" name="#{name}" value="#{result'}" pattern="[+0][ 0123456789]*" title="Only '+', spaces and numbers are allowed" "*{otherAttributes} :isRequired:required="true">
|
||||
|]
|
||||
, fieldEnctype = UrlEncoded
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue