8000 GitHub - rluiten/mailcheck at 4.1.0
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

rluiten/mailcheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mailcheck

An Elm library to suggest a correct domain when users misspell email addresses.

This is a port of mailcheck.js at https://github.com/mailcheck/mailcheck

What does it do?

When your user types in "user@gmil.con", it will suggest "user@gmail.com".

It is currently worth looking at the documentation at https://github.com/mailcheck/mailcheck

4.1.0 2015/12/30

Thanks to https://github.com/Adrian2112 for a pull request, he created the
`mailParts` functiion. I have retained `splitEmail` in API to make the version
 hange a Minor, but it now just uses the mailParts logic. Adrian also
 contributed a few refactors I have pulled in manually.

Installation

    elm package install rluiten/elm-mailcheck

Testing

See tests directory.

Execute TestRunner.elm in tests folder to run tests.

Example1.elm

import Mailcheck exposing (suggest)


input1 = "user@gmil.com"
mailcheckResult1 = suggest input1
test1Pass = mailcheckResult1 == Just ("user", "gmail.com", "user@gmail.com")


-- input2 = "user@gsnail.com"
input2 = "user@googlemail.com"
mailcheckResult2 = suggest input2
test2Pass = mailcheckResult2 == Nothing


_ = Debug.log("mailcheckResult1") (input1, mailcheckResult1, test1Pass)
_ = Debug.log("mailcheckResult2") (input2, mailcheckResult2, test2Pass)

Example2.elm

It is possible to provide your own list of domains, second level domains and top level domains.

import Mailcheck exposing (suggestWith)

domains = [ "yohomail.com" ]
secondLevelDomains = [ "supamail" ]
topLevelDomains = [ "cosmic" ]


input1 = "test@ohomail.co"
mailcheckResult1 =
    suggestWith domains secondLevelDomains topLevelDomains input1
test1Pass =
    mailcheckResult1 == Just ("test", "yohomail.com", "test@yohomail.com")


input2 = "test@fakedomain.comic"
mailcheckResult2 =
    suggestWith domains secondLevelDomains topLevelDomains input2
test2Pass =
    mailcheckResult2 == Just ("test", "fakedomain.cosmic", "test@fakedomain.cosmic")


input3 = "test@supermail.tld"
mailcheckResult3 =
    suggestWith domains secondLevelDomains topLevelDomains input3
test3Pass =
    mailcheckResult3 == Just ("test", "supamail.tld", "test@supamail.tld")


_ = Debug.log("mailcheckResult1") (input1, mailcheckResult1, test1Pass)
_ = Debug.log("mailcheckResult2") (input2, mailcheckResult2, test2Pass)
_ = Debug.log("mailcheckResult3") (input3, mailcheckResult3, test3Pass)

License

Released under the BSD3 License.

About

Port to Elm of mailcheck.js, suggests domains for emails with errors.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 5

Languages

0