Text.Email.Validate

email-validate-2.3.2.21: Email address validation

Safe Haskell | Safe-Inferred
Language | Haskell2010

Text.Email.Validate

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 #

Validates whether a particular string is an email address according to RFC5322.

validate :: ByteString -> Either String EmailAddress #

If you want to find out *why* a particular string is not an email address, use this.

Examples (both require `OverloadedStrings` to be enabled):

    >>> validate "example@example.com"
    Right "example@example.com"

    >>> validate "not.good"
    Left "at sign > @: not enough input"

emailAddress :: ByteString -> Maybe EmailAddress #

Smart constructor for an email address

canonicalizeEmail :: ByteString -> Maybe ByteString #

Checks that an email is valid and returns a version of it where comments and whitespace have been removed.

Example (requires `OverloadedStrings` to be enabled):

    >>> canonicalizeEmail "spaces. are. allowed@example.com"
    Just "spaces.are.allowed@example.com"

data EmailAddress #

Represents an email address.

#### Instances

Instances details

Data EmailAddress # |
Instance details Defined in Text.Email.Parser Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> EmailAddress -> c EmailAddress # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c EmailAddress # toConstr :: EmailAddress -> Constr # dataTypeOf :: EmailAddress -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c EmailAddress) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EmailAddress) # gmapT :: (forall b. Data b => b -> b) -> EmailAddress -> EmailAddress # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> EmailAddress -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> EmailAddress -> r # gmapQ :: (forall d. Data d => d -> u) -> EmailAddress -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> EmailAddress -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> EmailAddress -> m EmailAddress # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> EmailAddress -> m EmailAddress # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> EmailAddress -> m EmailAddress #
Generic EmailAddress # |
Instance details Defined in Text.Email.Parser Associated Types
type Rep EmailAddress |
Instance details Defined in Text.Email.Parser type Rep EmailAddress = D1 ('MetaData "EmailAddress" "Text.Email.Parser" "email-validate-2.3.2.21-2BiHh4QeHNs4Pk0NHG2BNN" 'False) (C1 ('MetaCons "EmailAddress" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))
Methods from :: EmailAddress -> Rep EmailAddress x # to :: Rep EmailAddress x -> EmailAddress #
Read EmailAddress # |
Instance details Defined in Text.Email.Parser Methods readsPrec :: Int -> ReadS EmailAddress # readList :: ReadS [EmailAddress] # readPrec :: ReadPrec EmailAddress # readListPrec :: ReadPrec [EmailAddress] #
Show EmailAddress # |
Instance details Defined in Text.Email.Parser Methods showsPrec :: Int -> EmailAddress -> ShowS # show :: EmailAddress -> String # showList :: [EmailAddress] -> ShowS #
Eq EmailAddress # |
Instance details Defined in Text.Email.Parser Methods (==) :: EmailAddress -> EmailAddress -> Bool # (/=) :: EmailAddress -> EmailAddress -> Bool #
Ord EmailAddress # |
Instance details Defined in Text.Email.Parser Methods compare :: EmailAddress -> EmailAddress -> Ordering # (<) :: EmailAddress -> EmailAddress -> Bool # (<=) :: EmailAddress -> EmailAddress -> Bool # (>) :: EmailAddress -> EmailAddress -> Bool # (>=) :: EmailAddress -> EmailAddress -> Bool # max :: EmailAddress -> EmailAddress -> EmailAddress # min :: EmailAddress -> EmailAddress -> EmailAddress #
type Rep EmailAddress # |
Instance details Defined in Text.Email.Parser type Rep EmailAddress = D1 ('MetaData "EmailAddress" "Text.Email.Parser" "email-validate-2.3.2.21-2BiHh4QeHNs4Pk0NHG2BNN" 'False) (C1 ('MetaCons "EmailAddress" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

domainPart :: EmailAddress -> ByteString #

Extracts the domain part of an email address.

localPart :: EmailAddress -> ByteString #

Extracts the local part of an email address.

toByteString :: EmailAddress -> ByteString #

Converts an email address back to a ByteString

unsafeEmailAddress :: ByteString -> ByteString -> EmailAddress #

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).