core.bones.email

Module Contents

Classes

EmailBone

The EmailBone class is a designed to store syntactically validated email addresses.

class core.bones.email.EmailBone(*, caseSensitive=True, max_length=254, min_length=None, natural_sorting=False, **kwargs)

Bases: viur.core.bones.string.StringBone

The EmailBone class is a designed to store syntactically validated email addresses.

This class provides an email validation method, ensuring that the given email address conforms to the required format and structure.

Initializes a new StringBone.

Parameters:
  • caseSensitive (bool) – When filtering for values in this bone, should it be case-sensitive?

  • max_length (int | None) – The maximum length allowed for values of this bone. Set to None for no limitation.

  • min_length (int | None) – The minimum length allowed for values of this bone. Set to None for no limitation.

  • natural_sorting (bool | Callable) – Allows a more natural sorting than the default sorting on the plain values. This uses the .sort_idx property. True enables sorting according to DIN 5007 Variant 2. With passing a callable, a custom transformer method can be set that creates the value for the index property.

  • kwargs – Inherited arguments from the BaseBone.

type = 'str.email'

A string representing the type of the bone, in this case “str.email”.

isInvalid(value)

Checks if the provided email address is valid or not.

Parameters:

value (str) – The email address to be validated.

Returns:

An error message if the email address is invalid or None if it is valid.

Return type:

str, None

The method checks if the provided email address is valid according to the following criteria:

  1. The email address must not be empty.

  2. The email address must be shorter than 256 characters.

  3. The local part (account) must be shorter than or equal to 64 characters.

  4. The email address must contain an “@” symbol, separating the local part (account) and the domain part.

  5. The domain part must be a valid IDNA-encoded string and should not contain any spaces.

  6. The local part (account) should only contain valid characters.

  7. The local part (account) can also contain Unicode characters within the range of U+0080 to U+10FFFF.