Home / Class/ EmailStr Class — fastapi Architecture

EmailStr Class — fastapi Architecture

Architecture documentation for the EmailStr class in models.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  485b4af3_9c75_263f_4293_de54b29e9b3a["EmailStr"]
  7f688779_6b22_3c15_6514_97dec91c3c30["models.py"]
  485b4af3_9c75_263f_4293_de54b29e9b3a -->|defined in| 7f688779_6b22_3c15_6514_97dec91c3c30
  79fe008b_320b_71fd_0d15_a66626e96546["__get_validators__()"]
  485b4af3_9c75_263f_4293_de54b29e9b3a -->|method| 79fe008b_320b_71fd_0d15_a66626e96546
  197dc748_a445_1ef1_c0ca_67e4cc9589fd["validate()"]
  485b4af3_9c75_263f_4293_de54b29e9b3a -->|method| 197dc748_a445_1ef1_c0ca_67e4cc9589fd
  20ea4a11_aece_5926_4bf5_5da699da083d["_validate()"]
  485b4af3_9c75_263f_4293_de54b29e9b3a -->|method| 20ea4a11_aece_5926_4bf5_5da699da083d
  9f33e086_0452_f4ea_6ce0_aeca33dce3a9["__get_pydantic_json_schema__()"]
  485b4af3_9c75_263f_4293_de54b29e9b3a -->|method| 9f33e086_0452_f4ea_6ce0_aeca33dce3a9
  20422701_2116_3e6b_55d1_bfb671aa4855["__get_pydantic_core_schema__()"]
  485b4af3_9c75_263f_4293_de54b29e9b3a -->|method| 20422701_2116_3e6b_55d1_bfb671aa4855

Relationship Graph

Source Code

fastapi/openapi/models.py lines 23–54

    class EmailStr(str):  # type: ignore
        @classmethod
        def __get_validators__(cls) -> Iterable[Callable[..., Any]]:
            yield cls.validate

        @classmethod
        def validate(cls, v: Any) -> str:
            logger.warning(
                "email-validator not installed, email fields will be treated as str.\n"
                "To install, run: pip install email-validator"
            )
            return str(v)

        @classmethod
        def _validate(cls, __input_value: Any, _: Any) -> str:
            logger.warning(
                "email-validator not installed, email fields will be treated as str.\n"
                "To install, run: pip install email-validator"
            )
            return str(__input_value)

        @classmethod
        def __get_pydantic_json_schema__(
            cls, core_schema: Mapping[str, Any], handler: GetJsonSchemaHandler
        ) -> dict[str, Any]:
            return {"type": "string", "format": "email"}

        @classmethod
        def __get_pydantic_core_schema__(
            cls, source: type[Any], handler: Callable[[Any], Mapping[str, Any]]
        ) -> Mapping[str, Any]:
            return with_info_plain_validator_function(cls._validate)

Domain

Frequently Asked Questions

What is the EmailStr class?
EmailStr is a class in the fastapi codebase, defined in fastapi/openapi/models.py.
Where is EmailStr defined?
EmailStr is defined in fastapi/openapi/models.py at line 23.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free