Giter Site home page Giter Site logo

truemail-rb / truemail-go Goto Github PK

View Code? Open in Web Editor NEW
94.0 2.0 16.0 213 KB

πŸš€ Configurable Golang πŸ“¨ email validator/verifier. Verify email via Regex, DNS, SMTP and even more. Be sure that email address valid and exists.

Home Page: https://truemail-rb.org/truemail-go

License: MIT License

Go 98.89% Shell 1.11%
go golang go-package email email-validation email-verification hacktoberfest mx-validation dns-validation email-validator

truemail-go's Introduction

Truemail - configurable framework agnostic plain Go email validator

Go Report Card Codecov CircleCI GitHub release (latest by date) PkgGoDev Mentioned in Awesome Go GitHub Contributor Covenant

Configurable Golang πŸ“¨ email validator. Verify email via Regex, DNS, SMTP and even more. Be sure that email address valid and exists. It's Golang port of truemail Ruby gem. Currently ported all validation features only.

Actual and maintainable documentation πŸ“š for developers is living here.

Table of Contents

Synopsis

Email validation is a tricky thing. There are a number of different ways to validate an email address and all mechanisms must conform with the best practices and provide proper validation. The truemail-go package helps you validate emails via regex pattern, presence of DNS records, and real existence of email account on a current email server.

Syntax Checking: Checks the email addresses via regex pattern.

Mail Server Existence Check: Checks the availability of the email address domain using DNS records.

Mail Existence Check: Checks if the email address really exists and can receive email via SMTP connections and email-sending emulation techniques.

Features

  • Configurable validator, validate only what you need
  • Supporting of internationalized emails (EAI)
  • Whitelist/blacklist validation layers
  • Ability to configure different MX/SMTP validation flows
  • Ability to configure DEA validation flow
  • Simple SMTP debugger

Requirements

Golang 1.21+

Installation

Install truemail-go:

go get github.com/truemail-rb/truemail-go
go install -i github.com/truemail-rb/truemail-go

Import truemail-go dependency into your code:

package main

import "github.com/truemail-rb/truemail-go"

Usage

Configuration features

You can use global package configuration or custom independent configuration. Available configuration options:

  • verifier email
  • verifier domain
  • email pattern
  • connection timeout
  • response timeout
  • connection attempts
  • default validation type
  • validation type for domains
  • whitelisted domains
  • whitelist validation
  • blacklisted domains
  • blacklisted mx ip-addresses
  • custom DNS gateway
  • RFC MX lookup flow
  • SMTP port number
  • SMTP error body pattern
  • SMTP fail fast
  • SMTP safe check

Creating configuration

To have an access for library features, you must create configuration struct first. Please use truemail.NewConfiguration() built-in constructor to create a valid configuration as in the example below:

import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(
  ConfigurationAttr{
    // Required parameter. Must be an existing email on behalf of which verification will be
    // performed
    VerifierEmail: "[email protected]",

    // Optional parameter. Must be an existing domain on behalf of which verification will be
    // performed. By default verifier domain based on verifier email
    VerifierDomain: "somedomain.com",

    // Optional parameter. You can override default regex pattern
    EmailPattern: `\A.+@(.+)\z`,

    // Optional parameter. You can override default regex pattern
    SmtpErrorBodyPattern: `.*(user|account).*`,

    // Optional parameter. Connection timeout in seconds.
    // It is equal to 2 by default.
    ConnectionTimeout: 1,

    // Optional parameter. A SMTP server response timeout in seconds.
    // It is equal to 2 by default.
    ResponseTimeout: 1,

    // Optional parameter. Total of connection attempts. It is equal to 2 by default.
    // This parameter uses in mx lookup timeout error and smtp request (for cases when
    // there is one mx server).
    ConnectionAttempts: 1,

    // Optional parameter. You can predefine default validation type for
    // truemail.Validate("[email protected]", configuration) call without type-parameter
    // Available validation types: "regex", "mx", "mx_blacklist", "smtp"
    ValidationTypeDefault: "mx",

    // Optional parameter. You can predefine which type of validation will be used for domains.
    // Also you can skip validation by domain.
    // Available validation types: "regex", "mx", "smtp"
    // This configuration will be used over current or default validation type parameter
    // All of validations for "somedomain.com" will be processed with regex validation only.
    // And all of validations for "otherdomain.com" will be processed with mx validation only.
    // It is equal to empty map of strings by default.
    ValidationTypeByDomain: map[string]string{"somedomain.com": "regex", "otherdomain.com": "mx"},

    // Optional parameter. Validation of email which contains whitelisted domain always will
    // return true. Other validations will not processed even if it was defined in
    // validationTypeByDomain. It is equal to empty slice of strings by default.
    WhitelistedDomains: []string{"somedomain1.com", "somedomain2.com"},

    // Optional parameter. With this option Truemail will validate email which contains whitelisted
    // domain only, i.e. if domain whitelisted, validation will passed to Regex, MX or SMTP
    // validators. Validation of email which not contains whitelisted domain always will return
    // false. It is equal false by default.
    WhitelistValidation: true,

    // Optional parameter. Validation of email which contains blacklisted domain always will
    // return false. Other validations will not processed even if it was defined in
    // validationTypeByDomain. It is equal to empty slice of strings by default.
    BlacklistedDomains: []string{"somedomain3.com", "somedomain4.com"},

    // Optional parameter. With this option Truemail will filter out unwanted mx servers via
    // predefined list of ip addresses. It can be used as a part of DEA (disposable email
    // address) validations. It is equal to empty slice of strings by default.
    BlacklistedMxIpAddresses: []string{"1.1.1.1", "2.2.2.2"},

    // Optional parameter. This option will provide to use custom DNS gateway when Truemail
    // interacts with DNS. Valid port number is in the range 1-65535. If you won't specify
    // nameserver port Truemail will use default DNS TCP/UDP port 53. It means that you can
    // use ip4 addres as DNS gateway, for example "10.0.0.1". By default Truemail uses
    // DNS gateway from system settings and this option is equal to empty string.
    Dns: "10.0.0.1:5300",

    // Optional parameter. This option will provide to use not RFC MX lookup flow.
    // It means that MX and Null MX records will be cheked on the DNS validation layer only.
    // By default this option is disabled and equal to false.
    NotRfcMxLookupFlow: true,

    // Optional parameter. SMTP port number. It is equal to 25 by default.
    // This parameter uses for SMTP session in SMTP validation layer.
    SmtpPort: 2525,

    // Optional parameter. This option will provide to use smtp fail fast behavior. When
    // smtpFailFast = true it means that Truemail ends smtp validation session after first
    // attempt on the first mx server in any fail cases (network connection/timeout error,
    // smtp validation error). This feature helps to reduce total time of SMTP validation
    // session up to 1 second. By default this option is disabled and equal to false.
    SmtpFailFast: true,

    // Optional parameter. This option will be parse bodies of SMTP errors. It will be helpful
    // if SMTP server does not return an exact answer that the email does not exist
    // By default this option is disabled, available for SMTP validation only.
    SmtpSafeCheck: true,
  },
)

Using configuration

import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(truemail.ConfigurationAttr{VerifierEmail: "[email protected]"})

truemail.Validate("[email protected]", configuration)
truemail.IsValid("[email protected]", configuration, "regex")

Validation features

Whitelist/Blacklist check

Whitelist/Blacklist check is zero validation level. You can define white and black list domains. It means that validation of email which contains whitelisted domain always will return true, and for blacklisted domain will return false.

Please note, other validations will not processed even if it was defined in ValidationTypeByDomain.

Sequence of domain list check:

  1. Whitelist check
  2. Whitelist validation check
  3. Blacklist check

Example of usage:

import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(
  truemail.ConfigurationAttr{
    VerifierEmail: "[email protected]",
    WhitelistedDomains: []string{"white-domain.com", "somedomain.com"},
    BlacklistedDomains: []string{"black-domain.com", "somedomain.com"},
    ValidationTypeByDomain: map[string]string{"somedomain.com": "mx"},
  },
)
Whitelist case

When email in whitelist, validation type will be redefined. Validation result returns true

import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(
  truemail.ConfigurationAttr{
    VerifierEmail: "[email protected]",
    WhitelistedDomains: []string{"white-domain.com", "somedomain.com"},
    BlacklistedDomains: []string{"black-domain.com", "somedomain.com"},
    ValidationTypeByDomain: map[string]string{"somedomain.com": "mx"},
  },
)

truemail.Validate("[email protected]", configuration) // returns pointer to ValidatorResult with validation details and error
truemail.IsValid("[email protected]", configuration) // returns true
Whitelist validation case

When email domain in whitelist and WhitelistValidation is sets equal to true validation type will be passed to other validators. Validation of email which not contains whitelisted domain always will return false.

Email has whitelisted domain
import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(
  truemail.ConfigurationAttr{
    VerifierEmail: "[email protected]",
    WhitelistedDomains: []string{"white-domain.com"},
    WhitelistValidation: true,
  },
)

truemail.Validate("[email protected]", configuration, "regex") // returns pointer to ValidatorResult with validation details and error
truemail.IsValid("[email protected]", configuration, "regex") // returns true
Email hasn't whitelisted domain
import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(
  truemail.ConfigurationAttr{
    VerifierEmail: "[email protected]",
    WhitelistedDomains: []string{"white-domain.com"},
    WhitelistValidation: true,
  },
)

truemail.Validate("[email protected]", configuration, "regex") // returns pointer to ValidatorResult with validation details and error
truemail.IsValid("[email protected]", configuration, "regex") // returns false
Blacklist case

When email in blacklist, validation type will be redefined too. Validation result returns false.

import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(
  truemail.ConfigurationAttr{
    VerifierEmail: "[email protected]",
    WhitelistedDomains: []string{"white-domain.com", "somedomain.com"},
    BlacklistedDomains: []string{"black-domain.com", "somedomain.com"},
    ValidationTypeByDomain: map[string]string{"somedomain.com": "mx"},
  },
)

truemail.Validate("[email protected]", configuration) // returns pointer to ValidatorResult with validation details and error
truemail.IsValid("[email protected]", configuration) // returns false
Duplication case

Validation result for this email returns true, because it was found in whitelisted domains list first. Also ValidatorResult.ValidationType for this case will be redefined.

import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(
  truemail.ConfigurationAttr{
    VerifierEmail: "[email protected]",
    WhitelistedDomains: []string{"white-domain.com", "somedomain.com"},
    BlacklistedDomains: []string{"black-domain.com", "somedomain.com"},
    ValidationTypeByDomain: map[string]string{"somedomain.com": "mx"},
  },
)

truemail.Validate("[email protected]", configuration) // returns pointer to ValidatorResult with validation details and error
truemail.IsValid("[email protected]", configuration) // returns true

Regex validation

Validation with regex pattern is the first validation level. It uses whitelist/blacklist check before running itself.

[Whitelist/Blacklist] -> [Regex validation]

By default this validation not performs strictly following RFC 5322 standard, so you can override truemail default regex pattern if you want.

Example of usage:

With default regex pattern
import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(
  truemail.ConfigurationAttr{
    VerifierEmail: "[email protected]",
  },
)

truemail.Validate("[email protected]", configuration, "regex") // returns pointer to ValidatorResult with validation details and error
truemail.IsValid("[email protected]", configuration, "regex") // returns true
With custom regex pattern

You should define your custom regex pattern in a gem configuration before.

import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(
  truemail.ConfigurationAttr{
    VerifierEmail: "[email protected]",
    EmailPattern: `\A(.+)@(.+)\z`,
  },
)

truemail.Validate("[email protected]", configuration, "regex") // returns pointer to ValidatorResult with validation details and error
truemail.IsValid("[email protected]", configuration, "regex") // returns true
truemail.IsValid("not_email", configuration, "regex") // returns false

MX validation

In fact it's DNS validation because it checks not MX records only. DNS validation is the second validation level, historically named as MX validation. It uses Regex validation before running itself. When regex validation has completed successfully then runs itself.

[Whitelist/Blacklist] -> [Regex validation] -> [MX validation]

Please note, truemail MX validator not performs strict compliance of the RFC 5321 standard for best validation outcome.

RFC MX lookup flow

Truemail MX lookup based on RFC 5321. It consists of 3 substeps: MX, CNAME and A record resolvers. The point of each resolver is attempt to extract the mail servers from email domain. If at least one server exists that validation is successful. Iteration is processing until resolver returns true.

Example of usage:

import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(
  truemail.ConfigurationAttr{
    VerifierEmail: "[email protected]",
  },
)

truemail.Validate("[email protected]", configuration, "mx") // returns pointer to ValidatorResult with validation details and error
truemail.IsValid("[email protected]", configuration, "mx") // returns bool
Not RFC MX lookup flow

Also Truemail has possibility to use not RFC MX lookup flow. It means that will be used only one MX resolver on the DNS validation layer. By default this option is disabled.

Example of usage:

import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(
  truemail.ConfigurationAttr{
    VerifierEmail: "[email protected]",
    NotRfcMxLookupFlow: true,
  },
)

truemail.Validate("[email protected]", configuration, "mx") // returns pointer to ValidatorResult with validation details and error
truemail.IsValid("[email protected]", configuration, "mx") // returns bool

MX blacklist validation

MX blacklist validation is the third validation level. This layer provides checking extracted mail server(s) IP address from MX validation with predefined blacklisted IP addresses list. It can be used as a part of DEA (disposable email address) validations.

[Whitelist/Blacklist] -> [Regex validation] -> [MX validation] -> [MX blacklist validation]

Example of usage:

import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(
  truemail.ConfigurationAttr{
    VerifierEmail: "[email protected]",
    BlacklistedMxIpAddresses: []string{"127.0.1.2", "127.0.1.3"},
  },
)

truemail.Validate("[email protected]", configuration, "mx_blacklist") // returns pointer to ValidatorResult with validation details and error
truemail.IsValid("[email protected]", configuration, "mx_blacklist") // returns bool

SMTP validation

SMTP validation is a final, fourth validation level. This type of validation tries to check real existence of email account on a current email server. This validation runs a chain of previous validations and if they're complete successfully then runs itself.

[Whitelist/Blacklist] -> [Regex validation] -> [MX validation] -> [MX blacklist validation] -> [SMTP validation]

If total count of MX servers is equal to one, truemail SMTP validator will use value from ConnectionAttempts as connection attempts. By default it's equal 2.

By default, you don't need pass with-parameter to use it. Example of usage is specified below:

SMTP fail fast enabled

Truemail can use fail fast behavior for SMTP validation layer. When SmtpFailFast = true it means that truemail ends smtp validation session after first attempt on the first mx server in any fail cases (network connection/timeout error, smtp validation error). This feature helps to reduce total time of SMTP validation session up to 1 second.

import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(
  truemail.ConfigurationAttr{
    VerifierEmail: "[email protected]",
    SmtpFailFast: true,
  },
)

truemail.Validate("[email protected]", configuration) // returns pointer to ValidatorResult with validation details and error
truemail.IsValid("[email protected]", configuration) // returns bool
SMTP safe check disabled

When this feature disabled, it means that SMTP validation will be failed when it consists at least one smtp error.

import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(
  truemail.ConfigurationAttr{
    VerifierEmail: "[email protected]",
  },
)

truemail.Validate("[email protected]", configuration) // returns pointer to ValidatorResult with validation details and error
truemail.IsValid("[email protected]", configuration) // returns bool
SMTP safe check enabled

When this feature enabled, it means that SMTP validation will be successful for all cases until truemail SMTP validator receive RCPT TO error that matches to SmtpErrorBodyPattern, specified in configuration.

import "github.com/truemail-rb/truemail-go"

configuration := truemail.NewConfiguration(
  truemail.ConfigurationAttr{
    VerifierEmail: "[email protected]",
    SmtpSafeCheck: true,
  },
)

truemail.Validate("[email protected]", configuration) // returns pointer to ValidatorResult with validation details and error
truemail.IsValid("[email protected]", configuration) // returns bool

Truemail helpers

.IsValid()

You can use the .IsValid() helper for quick validation of email address. It returns a boolean:

truemail.IsValid("[email protected]", configuration)

Truemail family

All Truemail solutions: https://truemail-rb.org

Name Type Description
truemail ruby gem Configurable framework agnostic plain Ruby email validator, main core
truemail server ruby app Lightweight rack based web API wrapper for Truemail gem
truemail-rack-docker docker image Lightweight rack based web API dockerized image 🐳 of Truemail server
truemail-ruby-client ruby gem Web API Ruby client for Truemail Server
truemail-crystal-client crystal shard Web API Crystal client for Truemail Server
truemail-java-client java lib Web API Java client for Truemail Server
truemail-rspec ruby gem Truemail configuration, auditor and validator RSpec helpers

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/truemail-rb/truemail-go. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct. Please check the open tickets. Be sure to follow Contributor Code of Conduct below and our Contributing Guidelines.

License

The package is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Truemail project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Credits

Versioning

Truemail uses Semantic Versioning 2.0.0

truemail-go's People

Contributors

bestwebua avatar richimaulana avatar

Stargazers

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

Watchers

 avatar  avatar

truemail-go's Issues

[QUESTION] I am experiencing difficulties validating emails using the TrueMail API on my Local Ubuntu System

Hello Team,

I'm a PHP Laravel developer with no prior experience in Go. I've installed Go version go1.21.6 on Linux/amd64. I am looking to validate emails with domain and MX records using Go.

I've attempted to run go build, go run ., and go run [specific files], but encountered various errors each time.

Could you please guide me through the necessary steps to run this validation process so that I can effectively validate emails?

Thank you.

[QUESTION] Is it possible to do validation after the RCPT TO section in the SMTP session?

New question checklist

Question

When using Truemail as my main engine for validating emails I found that every time I validate Yahoo emails the results are always valid/true. After I try to debug the problems, turn out that Yahoo accepts all email addresses in the RCPT TO section, so even if the email doesn't exist the return from the Yahoo MX server will always be OK (250). After I continued to the DATA section in the SMTP session the Yahoo MX server just returned the mailbox not exist message.

Here is the detail:

$ swaks -s mta5.am0.yahoodns.net:25 -f [email protected] -t [email protected]
=== Trying mta5.am0.yahoodns.net:25...
=== Connected to mta5.am0.yahoodns.net.
<-  220 mtaproxy511.free.mail.bf1.yahoo.com ESMTP ready
 -> EHLO vpndev.aktiva.co.id
<-  250-mtaproxy511.free.mail.bf1.yahoo.com
<-  250-PIPELINING
<-  250-SIZE 41943040
<-  250-8BITMIME
<-  250 STARTTLS
 -> MAIL FROM:<[email protected]>
<-  250 sender <[email protected]> ok
 -> RCPT TO:<[email protected]>
<-  250 recipient <[email protected]> ok
 -> DATA
<-  354 go ahead
 -> Date: Tue, 30 Apr 2024 04:24:03 +0000
 -> To: [email protected]
 -> From: [email protected]
 -> Subject: test Tue, 30 Apr 2024 04:24:03 +0000
 -> Message-Id: <[email protected]>
 -> X-Mailer: swaks v20190914.0 jetmore.org/john/code/swaks/
 ->
 -> This is a test mailing
 ->
 ->
 -> .
<** 552 1 Requested mail action aborted, mailbox not found
 -> QUIT
*** Remote host closed connection unexpectedly.

So is there any workaround for this problem? I tried various validators that are available online and the result is valid.

Is the only way is just to do/continue the SMTP session until the DATA section? If it is, doesn't it will send the message to the target email if the email is valid?

[BUG] Email Pattern validation causes runtime error

New bug checklist

Bug description

When and email does not have a domain it will throw a panic runtime error: index out of range [1] with length 0.

Complete output when running truemail, including the stack trace and command used
panic: runtime error: index out of range [1] with length 0

goroutine 1 [running]:
github.com/truemail-rb/truemail-go.regexCaptureGroup({0x4000246b70, 0x3}, {0x277365?, 0x400077a240?}, 0x1)
/home/parallels/go/pkg/mod/github.com/truemail-rb/[email protected]/helpers.go:82 +0x74
github.com/truemail-rb/truemail-go.emailDomain(...)
/home/parallels/go/pkg/mod/github.com/truemail-rb/[email protected]/helpers.go:87
github.com/truemail-rb/truemail-go.(*validationDomainListMatch).setValidatorResultDomain(...)
/home/parallels/go/pkg/mod/github.com/truemail-rb/[email protected]/domain_list_match.go:40
github.com/truemail-rb/truemail-go.(*validationDomainListMatch).check(0x4000580110, 0x400059a160)
/home/parallels/go/pkg/mod/github.com/truemail-rb/[email protected]/domain_list_match.go:9 +0x6c
github.com/truemail-rb/truemail-go.(*validator).validateDomainListMatch(...)
/home/parallels/go/pkg/mod/github.com/truemail-rb/[email protected]/validator.go:84
github.com/truemail-rb/truemail-go.(*validator).run(0x40003abd90)
/home/parallels/go/pkg/mod/github.com/truemail-rb/[email protected]/validator.go:158 +0x70
github.com/truemail-rb/truemail-go.Validate({0x4000246b70, 0x3}, 0x40001810a0, {0x40003abec8?, 0x1?, 0x264f7b?})
/home/parallels/go/pkg/mod/github.com/truemail-rb/[email protected]/truemail.go:13 +0x228
main.validateEmails(0x28b2b1?)

[ISSUE] Typographical error on line 49 in domain_list_match.go file

New issue checklist

[ISSUE] Typographical error on line 49 in domain_list_match.go file

Issue description

// Returns true if whitelist validation enebled, otherwise returns false
func (validation *validationDomainListMatch) isWhitelistValidation() bool {
validatorResult := validation.result
return validatorResult.Configuration.WhitelistValidation
}

As seen above, the comment reads Returns true if whitelist validation "enabled"
This is a typo, as the word should be "enabled"

[QUESTION] Why smtpRequest is private ?

New question checklist

Question

It is not possible to easily access the content of truemail.validatorResult.SmtpDebug because the fields of smtpRequest are private. How to access easily to these fields ?

I would like to know why smtp check fail by look at SmtpDebug[i].response. Is that a choice to put those structs private ?

Thanks for your work

[BUG] There is an issue in the Validate function where it panics, root cause is in the runSession function

The bug is in the runSession function when creating smtp client we ignore the error, however calling either Send or Close in case there is an error causes panic

New bug checklist

Bug description

The bug is in the runSession function when creating smtp client we ignore the error on line 105, however calling either Send or Close in case there is an error causes panic:
Screenshot 2023-10-12 at 4 52 50 PM

[BUG] Email Pattern validation causes runtime error

New bug checklist

Bug description

When and email does not have a domain it will throw a panic runtime error: index out of range [1] with length 0.

Complete output when running truemail, including the stack trace and command used
panic: runtime error: index out of range [1] with length 0

goroutine 1 [running]:
github.com/truemail-rb/truemail-go.regexCaptureGroup({0x4000246b70, 0x3}, {0x277365?, 0x400077a240?}, 0x1)
/home/parallels/go/pkg/mod/github.com/truemail-rb/[email protected]/helpers.go:82 +0x74
github.com/truemail-rb/truemail-go.emailDomain(...)
/home/parallels/go/pkg/mod/github.com/truemail-rb/[email protected]/helpers.go:87
github.com/truemail-rb/truemail-go.(*validationDomainListMatch).setValidatorResultDomain(...)
/home/parallels/go/pkg/mod/github.com/truemail-rb/[email protected]/domain_list_match.go:40
github.com/truemail-rb/truemail-go.(*validationDomainListMatch).check(0x4000580110, 0x400059a160)
/home/parallels/go/pkg/mod/github.com/truemail-rb/[email protected]/domain_list_match.go:9 +0x6c
github.com/truemail-rb/truemail-go.(*validator).validateDomainListMatch(...)
/home/parallels/go/pkg/mod/github.com/truemail-rb/[email protected]/validator.go:84
github.com/truemail-rb/truemail-go.(*validator).run(0x40003abd90)
/home/parallels/go/pkg/mod/github.com/truemail-rb/[email protected]/validator.go:158 +0x70
github.com/truemail-rb/truemail-go.Validate({0x4000246b70, 0x3}, 0x40001810a0, {0x40003abec8?, 0x1?, 0x264f7b?})
/home/parallels/go/pkg/mod/github.com/truemail-rb/[email protected]/truemail.go:13 +0x228
main.validateEmails(0x28b2b1?)

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.