@@ -1,5 +1,6 @@
1{-# OPTIONS_GHC -Wno-orphans #-}
1{-# OPTIONS_GHC -Wno-orphans #-}
2{-# LANGUAGE CPP #-}
2{-# LANGUAGE CPP #-}
3module Text.Email.Extra
4module Text.Email.Extra
4 ( validateEmail
5 ( validateEmail
5 , emailToText
6 , emailToText
@@ -24,6 +25,10 @@ import Database.PostgreSQL.Simple.ToField as PG
24import Control.Monad
25import Control.Monad
25import Data.Aeson
26import Data.Aeson
28-- | Validate that the domain part in this email address is
33-- | Validate that the domain part in this email address is
29-- in fact a domain name.
34-- in fact a domain name.
@@ -105,3 +110,11 @@ instance ToJSON EmailAddress where
105instance FromJSON EmailAddress where
110instance FromJSON EmailAddress where
106 parseJSON = parseJSON >=> either fail pure . validateEmail . Text.encodeUtf8
111 parseJSON = parseJSON >=> either fail pure . validateEmail . Text.encodeUtf8
115+instance ToSchema EmailAddress where
116+ declareNamedSchema _ = declareNamedSchema (Proxy :: Proxy Text)
118+instance ToParamSchema EmailAddress where
119+ toParamSchema _ = toParamSchema (Proxy :: Proxy Text)