Coder Social home page Coder Social logo

mailcheckswift's Introduction

Mailcheck - Swift

The Swift library that suggests a right domain when your users misspell it in an email address. See the original at https://github.com/mailcheck/mailcheck.

When your user types in "[email protected]", Mailcheck will suggest "[email protected]".

Mailcheck will offer up suggestions for top level domains too, and suggest ".com" when a user types in "[email protected]".

Usage

import MailcheckSwift
let result: MailcheckSuggestion? = Mailcheck.suggest("[email protected]")

Result will contain nil if the domain appears to be valid. Otherwise the suggestion will be a MailcheckSuggestion struct that will contain the following fields:

address: String //e.g. "test"
domain: String  //e.g. "hotmail.com",
full: String    //e.g "[email protected]"

Customize maximum edit distance

You can customize the maximum edit distance. For instance with a threshold of 2:

Mailcheck.threshold = 2
Mailcheck.check("[email protected]")

will return a suggestion of "[email protected]". With a threshold of 1 no suggestion would be returned for this case. The default value is 3.

Checking if an e-mail is valid

Checks to see if an e-mail is valid format while also returning a suggestion

import MailcheckSwift
let result = Mailcheck.check("[email protected]")

Result will be a MailcheckResult struct with the following fields

valid: Bool //true or false
suggestion: MailcheckSuggestion? // e.g. MailcheckSuggestion(address: "test", domain: "hotmail.com", full: "[email protected]")

Checking against additional domains

Supply your own domain lists:

let result: MailcheckResult = Mailcheck.check("[email protected]", domains: ["mydomain.co"], topLevelDomains: ["co"])

Or add to the default list:

let result: MailcheckResult = Mailcheck.check:@"[email protected]" extraDomains:["mydomain.co"] extraTopLevelDomains:["co"]];

Maintainers

License

Licensed under the MIT License. Swift implementation of Mailcheck (http://getmailcheck.org/)

Thanks and References

This project was heavily influenced by the Objective-C implementation of Mailcheck (https://github.com/mailcheck/mailcheck-objectivec)

mailcheckswift's People

Contributors

brycehammond avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

brycehammond

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.