MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / validate_domain_part

Method validate_domain_part

mongoengine/fields.py:275–295  ·  view source on GitHub ↗

Validate the domain part of the email address. Return True if valid and False otherwise.

(self, domain_part)

Source from the content-addressed store, hash-verified

273 return self.USER_REGEX.match(user_part)
274
275 def validate_domain_part(self, domain_part):
276 """Validate the domain part of the email address. Return True if
277 valid and False otherwise.
278 """
279 # Skip domain validation if it's in the whitelist.
280 if domain_part in self.domain_whitelist:
281 return True
282
283 if self.DOMAIN_REGEX.match(domain_part):
284 return True
285
286 # Validate IPv4/IPv6, e.g. user@[192.168.0.1]
287 if self.allow_ip_domain and domain_part[0] == "[" and domain_part[-1] == "]":
288 for addr_family in (socket.AF_INET, socket.AF_INET6):
289 try:
290 socket.inet_pton(addr_family, domain_part[1:-1])
291 return True
292 except (OSError, UnicodeEncodeError):
293 pass
294
295 return False
296
297 def validate(self, value):
298 super().validate(value)

Callers 1

validateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected