Skip to content

tejaksha/emailcorrector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Emailcorrector

A Go package for validating and auto-correcting email addresses.

Features

  • Validate the format of an email address.
  • Suggest corrections for common domain name typos (e.g., gmial.comgmail.com).
  • Use the Levenshtein distance algorithm to detect and correct minor mistakes.

Installation

go get github.com/tejaksha/emailcorrector

Usage

package main

import (
    "fmt"
    "github.com/tejaksha/emailcorrector"
)

func main() {
    // Example of validating an email
    email := "[email protected]"
    if err := emailcorrector.ValidateEmail(email); err != nil {
        fmt.Println("Invalid email:", err)
    } else {
        fmt.Println("Valid email:", email)
    }

    // Example of suggesting a domain correction
    incorrectDomain := "gmial.com"
    suggested := emailcorrector.SuggestDomainCorrection(incorrectDomain)
    fmt.Printf("Did you mean: %s?
", suggested)

    // Example of correcting an email
    incorrectEmail := "[email protected]"
    corrected, err := emailcorrector.CorrectEmail(incorrectEmail)
    if err != nil {
        fmt.Println("Invalid email:", err)
    } else {
        fmt.Println("Corrected email:", corrected)
    }
}

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages