Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

email-domain-verification

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

email-domain-verification

Email Validator

  • 1.1.0
  • Source
  • PyPI
  • Socket score

Maintainers
1

Email Domain Verification Package

this package can provide some email validators with which users can validate their project emails far easily

Installation

your module will be installed by PYPI

pip install email-domain-verification

Usage

from email_domain_verification import Email, EmailVerifier
from email_domain_verification.validators import BlackDomainListValidator

# you can import any of these validators or write your own validator
# (
#     BlackDomainListValidator,
#     DomainExtensionValidator,
#     LengthValidator,
#     MultiDotValidator,
#     SafeDomainValidator,
#     SafeDomainValidatorOnline,
# )

email = Email("hello@gmail.com")
black_email_list = [
    "xyz-mail.com",
    "tempmail.com",
    "temp.com",
    "mail-temp.org",
    # ...
]
validators = [
    BlackDomainListValidator(black_email_list),
]

verifier = EmailVerifier(email)
verifier.verify(validators)

prevent raise exception

from email_domain_verification import Email, EmailVerifier
from email_domain_verification.validators import BlackDomainListValidator

email = Email("hello@gmail.com")
black_email_list = [
    "xyz-mail.com",
    "tempmail.com",
    # ...
]
validators = [
    BlackDomainListValidator(black_email_list),
]

verifier = EmailVerifier(email)
validated: bool = verifier.verify(validators, raise_exception=False)
# validated == True => email is safe | validated == False => email is unsafe

Create Custom Validator

from email_domain_verification import Email, EmailVerifier
from email_domain_verification.interfaces import ValidatorInterface
from email_domain_verification.validators import LengthValidator


class CustomValidator(ValidatorInterface):
    __criterion: typing.Type

    def __init__(self, criterion: typing.Type) -> None:
        self.__criterion = criterion

    def validate_criterion(self) -> None:
        # validate __criterion
        pass

    def check(self, email: Email) -> bool:
        self.validate_criterion()

        # check email.value
        # example: len(email.value) > self.__criterion: return True
        validate = True
        if not validate:
            raise ValueError("The Error Message")

        return True


email = Email("hello@gmail.com")
validators = [
    BlackDomainListValidator(black_email_list),
    CustomValidator(10),
]

verifier = EmailVerifier(email)
verifier.verify(validators)


FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc