Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- isValid :: ByteString -> Bool
- validate :: ByteString -> Either String EmailAddress
- emailAddress :: ByteString -> Maybe EmailAddress
- canonicalizeEmail :: ByteString -> Maybe ByteString
- data EmailAddress
- domainPart :: EmailAddress -> ByteString
- localPart :: EmailAddress -> ByteString
- toByteString :: EmailAddress -> ByteString
- unsafeEmailAddress :: ByteString -> ByteString -> EmailAddress
Documentation
isValid :: ByteString -> Bool Source #
Validates whether a particular string is an email address according to RFC5322.
validate :: ByteString -> Either String EmailAddress Source #
If you want to find out *why* a particular string is not an email address, use this.
Examples:
>>>
validate "example@example.com"
Right "example@example.com"
>>>
validate "not.good"
Left "at sign > @: not enough input"
emailAddress :: ByteString -> Maybe EmailAddress Source #
Smart constructor for an email address
canonicalizeEmail :: ByteString -> Maybe ByteString Source #
Checks that an email is valid and returns a version of it where comments and whitespace have been removed.
Example:
>>>
canonicalizeEmail "spaces. are. allowed@example.com"
Just "spaces.are.allowed@example.com"
data EmailAddress Source #
Represents an email address.
Instances
domainPart :: EmailAddress -> ByteString Source #
Extracts the domain part of an email address.
localPart :: EmailAddress -> ByteString Source #
Extracts the local part of an email address.
toByteString :: EmailAddress -> ByteString Source #
Converts an email address back to a ByteString
unsafeEmailAddress :: ByteString -> ByteString -> EmailAddress Source #
Creates an email address without validating it. You should only use this when reading data from somewhere it has already been validated (e.g. a database).