當前位置: 首頁>>代碼示例>>Python>>正文


Python email_validator.validate_email方法代碼示例

本文整理匯總了Python中email_validator.validate_email方法的典型用法代碼示例。如果您正苦於以下問題:Python email_validator.validate_email方法的具體用法?Python email_validator.validate_email怎麽用?Python email_validator.validate_email使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在email_validator的用法示例。


在下文中一共展示了email_validator.validate_email方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import email_validator [as 別名]
# 或者: from email_validator import validate_email [as 別名]
def __init__(self, email):
        """Initialize a new Email notification.

        Arguments:
            email: the email to notify. This value is validated a little
                   stricter than other notification values to prevent unwanted
                   behavior when a detector actually fires.
        """
        valid_email = validate_email(email, check_deliverability=False)
        self.options = {'type': 'Email', 'email': valid_email['email']} 
開發者ID:Nike-Inc,項目名稱:signal_analog,代碼行數:12,代碼來源:detectors.py

示例2: is_valid_email_address

# 需要導入模塊: import email_validator [as 別名]
# 或者: from email_validator import validate_email [as 別名]
def is_valid_email_address(email_address):
	"""
	Check that the string specified appears to be a valid email address.

	:param str email_address: The email address to validate.
	:return: Whether the email address appears to be valid or not.
	:rtype: bool
	"""
	if email_address is None:
		return False
	try:
		email_validator.validate_email(email_address, allow_empty_local=False, check_deliverability=False)
	except email_validator.EmailNotValidError:
		return False
	return True 
開發者ID:rsmusllp,項目名稱:king-phisher,代碼行數:17,代碼來源:utilities.py

示例3: validate_email

# 需要導入模塊: import email_validator [as 別名]
# 或者: from email_validator import validate_email [as 別名]
def validate_email(email):
    try:
        return email_validator.validate_email(email)["email"]
    except email_validator.EmailNotValidError as e:
        raise EmailNotValidException(str(e)) 
開發者ID:cgwire,項目名稱:zou,代碼行數:7,代碼來源:auth.py

示例4: validate_email_address

# 需要導入模塊: import email_validator [as 別名]
# 或者: from email_validator import validate_email [as 別名]
def validate_email_address(question, value):
        # Run the same checks as text (data type is str, stripped, and is not empty).
        value = validator.validate_text(question, value)

        # Then validate and normalize the value as an email address.
        # When we're running tests, skip DNS-based deliverability checks
        # so that tests can be run in a completely offline mode. Otherwise
        # dns.resolver.NoNameservers will result in EmailUndeliverableError.
        import email_validator
        from django.conf import settings
        info = email_validator.validate_email(value, check_deliverability=settings.VALIDATE_EMAIL_DELIVERABILITY)
        return info["email"] 
開發者ID:GovReady,項目名稱:govready-q,代碼行數:14,代碼來源:answer_validation.py

示例5: validate

# 需要導入模塊: import email_validator [as 別名]
# 或者: from email_validator import validate_email [as 別名]
def validate(cls, value: Union[str]) -> str:
        return validate_email(value)[1] 
開發者ID:samuelcolvin,項目名稱:pydantic,代碼行數:4,代碼來源:networks.py

示例6: validate_email

# 需要導入模塊: import email_validator [as 別名]
# 或者: from email_validator import validate_email [as 別名]
def validate_email(value: Union[str]) -> Tuple[str, str]:
    """
    Brutally simple email address validation. Note unlike most email address validation
    * raw ip address (literal) domain parts are not allowed.
    * "John Doe <local_part@domain.com>" style "pretty" email addresses are processed
    * the local part check is extremely basic. This raises the possibility of unicode spoofing, but no better
        solution is really possible.
    * spaces are striped from the beginning and end of addresses but no error is raised

    See RFC 5322 but treat it with suspicion, there seems to exist no universally acknowledged test for a valid email!
    """
    if email_validator is None:
        import_email_validator()

    m = pretty_email_regex.fullmatch(value)
    name: Optional[str] = None
    if m:
        name, value = m.groups()

    email = value.strip()

    try:
        email_validator.validate_email(email, check_deliverability=False)
    except email_validator.EmailNotValidError as e:
        raise errors.EmailError() from e

    at_index = email.index('@')
    local_part = email[:at_index]  # RFC 5321, local part must be case-sensitive.
    global_part = email[at_index:].lower()

    return name or local_part, local_part + global_part 
開發者ID:samuelcolvin,項目名稱:pydantic,代碼行數:33,代碼來源:networks.py


注:本文中的email_validator.validate_email方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。