MCPcopy Index your code
hub / github.com/JoshData/python-email-validator / check_dot_atom

Function check_dot_atom

email_validator/syntax.py:444–460  ·  view source on GitHub ↗
(label: str, start_descr: str, end_descr: str, is_hostname: bool)

Source from the content-addressed store, hash-verified

442
443
444def check_dot_atom(label: str, start_descr: str, end_descr: str, is_hostname: bool) -> None:
445 # RFC 5322 3.2.3
446 if label.endswith("."):
447 raise EmailSyntaxError(end_descr.format("period"))
448 if label.startswith("."):
449 raise EmailSyntaxError(start_descr.format("period"))
450 if ".." in label:
451 raise EmailSyntaxError("An email address cannot have two periods in a row.")
452
453 if is_hostname:
454 # RFC 952
455 if label.endswith("-"):
456 raise EmailSyntaxError(end_descr.format("hyphen"))
457 if label.startswith("-"):
458 raise EmailSyntaxError(start_descr.format("hyphen"))
459 if ".-" in label or "-." in label:
460 raise EmailSyntaxError("An email address cannot have a period and a hyphen next to each other.")
461
462
463def uts46_valid_char(char: str) -> bool:

Callers 2

Calls 1

EmailSyntaxErrorClass · 0.85

Tested by

no test coverage detected