Code Monkey home page Code Monkey logo

emailcorrect's Introduction

EmailCorrect

Preview

Intelligently validate email addresses.

Usage

EmailCorrect *emailCorrector = [[[EmailCorrect alloc] init] autorelease];

// Validate an email address, offer a suggestion if the domain is invalid
EmailCorrectionHandler correctionHandler = ^(NSString *triedEmail, NSString *correction, NSString *email) {
	UIAlertView *alert = [[[UIAlertView alloc] init] autorelease];
	[alert setTitle:[NSString stringWithFormat:@"Did you mean %@?", correction]];
	NSString *message = [NSString stringWithFormat:@"Tried to use the invalid email %@, did you mean %@?", triedEmail, email];
	[alert setMessage:message];
	[alert addButtonWithTitle:@"Yes"];
	[alert addButtonWithTitle:@"No"];
	[alert show];
};
EmailValidHandler validHandler = ^(NSString *email) {
	NSLog(@"%@", [NSString stringWithFormat:@"Success! Email address '%@' is valid", email]);
};
EmailInvalidHandler invalidHandler = ^(NSString *invalidEmail) {
	NSLog(@"%@", [NSString stringWithFormat:@"Failed! Email address '%@' is invalid", invalidEmail]);
};
NSString *needsCorrection = @"[email protected]";
// Shows an alert view suggesting the domain be changed to '.com'
[emailCorrector validateEmailAddress:needsCorrection
                                       validHandler:validHandler
                                     invalidHandler:invalidHandler
                                  correctionHandler:correctionHandler];

Other utilities

// Check if an email is valid
[emailCorrector isValidEmail:@"[email protected]"];

// Check if a domain is valid
[emailCorrector isValidDomain:@".com"];

// Offer a suggestion for an invalid domain
NSString *suggestion = [emailCorrector correctionForDomain:@".con"];
NSLog(@"You typed '.con' did you mean '%@'?", suggestion);
// Prints
You typed '.con' did you mean '.com'?

emailcorrect's People

Contributors

jarodl avatar mattmmatt avatar nachosoto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

emailcorrect's Issues

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.