Email Validator
Project description
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)
Copyright (c) 2023, Khodnevisai.com (Mahdi Niknejad).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file email_domain_verification-1.1.0.tar.gz
.
File metadata
- Download URL: email_domain_verification-1.1.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 168d000bf64fc3f68c2542bf17681d5bc7bdbfcb41ccdaf9cc88e00e581b24dd |
|
MD5 | 1889a4116ac743df9c3e84ca4ef8abba |
|
BLAKE2b-256 | 5b3ca5aa0d703b7016b49cbd7d106b297eb01a75914bdeb99327a6ba92465074 |