email-validate 1.0.0
This commit is contained in:
parent
38292d6357
commit
c786b30afb
@ -60,6 +60,10 @@ import Text.Blaze (ToMarkup (toMarkup), preEscapedToMarkup, unsafeByteString)
|
|||||||
import Text.Cassius
|
import Text.Cassius
|
||||||
import Data.Time (Day, TimeOfDay(..))
|
import Data.Time (Day, TimeOfDay(..))
|
||||||
import qualified Text.Email.Validate as Email
|
import qualified Text.Email.Validate as Email
|
||||||
|
#if MIN_VERSION_email_validate(1, 0, 0)
|
||||||
|
import Data.Text.Encoding (encodeUtf8, decodeUtf8With)
|
||||||
|
import Data.Text.Encoding.Error (lenientDecode)
|
||||||
|
#endif
|
||||||
import Network.URI (parseURI)
|
import Network.URI (parseURI)
|
||||||
import Database.Persist (PersistField)
|
import Database.Persist (PersistField)
|
||||||
import Database.Persist.Store (Entity (..))
|
import Database.Persist.Store (Entity (..))
|
||||||
@ -291,9 +295,16 @@ timeParser = do
|
|||||||
emailField :: RenderMessage master FormMessage => Field sub master Text
|
emailField :: RenderMessage master FormMessage => Field sub master Text
|
||||||
emailField = Field
|
emailField = Field
|
||||||
{ fieldParse = parseHelper $
|
{ fieldParse = parseHelper $
|
||||||
|
#if MIN_VERSION_email_validate(1, 0, 0)
|
||||||
|
\s ->
|
||||||
|
case Email.canonicalizeEmail $ encodeUtf8 s of
|
||||||
|
Just e -> Right $ decodeUtf8With lenientDecode e
|
||||||
|
Nothing -> Left $ MsgInvalidEmail s
|
||||||
|
#else
|
||||||
\s -> if Email.isValid (unpack s)
|
\s -> if Email.isValid (unpack s)
|
||||||
then Right s
|
then Right s
|
||||||
else Left $ MsgInvalidEmail s
|
else Left $ MsgInvalidEmail s
|
||||||
|
#endif
|
||||||
, fieldView = \theId name attrs val isReq -> toWidget [hamlet|
|
, fieldView = \theId name attrs val isReq -> toWidget [hamlet|
|
||||||
$newline never
|
$newline never
|
||||||
<input id="#{theId}" name="#{name}" *{attrs} type="email" :isReq:required="" value="#{either id id val}">
|
<input id="#{theId}" name="#{name}" *{attrs} type="email" :isReq:required="" value="#{either id id val}">
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-form
|
name: yesod-form
|
||||||
version: 1.2.1
|
version: 1.2.1.1
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user