packages feed

email-validate 0.2.1 → 0.2.3

raw patch · 2 files changed

+27/−7 lines, 2 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Text.Email.Validate: EmailAddress :: String -> String -> EmailAddress
+ Text.Email.Validate: data EmailAddress
+ Text.Email.Validate: domainPart :: EmailAddress -> String
+ Text.Email.Validate: instance Show EmailAddress
+ Text.Email.Validate: localPart :: EmailAddress -> String
- Text.Email.Validate: validate :: String -> Either ParseError ()
+ Text.Email.Validate: validate :: String -> Either ParseError EmailAddress

Files

Text/Email/Validate.hs view
@@ -1,4 +1,4 @@-module Text.Email.Validate (isValid,validate)+module Text.Email.Validate (isValid,validate,EmailAddress(..)) where  import Control.Arrow ((***))@@ -7,6 +7,16 @@ import Text.Parsec.Char import Data.Char (chr) +-- | Constructor does no checking for invalid emails, so use at own risk.+data EmailAddress = EmailAddress+	{+		localPart :: String,+		domainPart :: String+	}++instance Show EmailAddress where+	show (EmailAddress l d) = l ++ ('@' : d)+ -- | Validates whether a particular string is an email address --   according to RFC5322. isValid :: String -> Bool@@ -17,12 +27,22 @@  -- | If you want to find out why a particular string is not --   an email address, use this!-validate :: String -> Either ParseError ()-validate = parse addrSpec ""--addrSpec = localPart >> char '@' >> domain >> eof+validate :: String -> Either ParseError EmailAddress+validate x = case parse addrSpec "" x of+	Right n -> Right $ EmailAddress local domain+		where (local,at:domain) = splitAt (length x - n) x+	Left e -> Left e+			+addrSpec :: Parsec String () Int+addrSpec = do+	localPartParser+	s1 <- getInput+	char '@'+	domain+	eof+	return (length s1) -localPart = dottedAtoms+localPartParser = dottedAtoms domain = dottedAtoms <|> domainLiteral   dottedAtoms = simply $ (optional cfws >> (atom <|> quotedString) >> optional cfws)
email-validate.cabal view
@@ -1,5 +1,5 @@ name:           email-validate-version:        0.2.1+version:        0.2.3 license:        BSD3 license-file:   LICENSE author:         George Pollard