Home / Function/ EmailStr() — fastapi Function Reference

EmailStr() — fastapi Function Reference

Architecture documentation for the EmailStr() function in models.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  3a13db06_7756_8b88_8330_0d14f9140935["EmailStr()"]
  7f688779_6b22_3c15_6514_97dec91c3c30["models.py"]
  3a13db06_7756_8b88_8330_0d14f9140935 -->|defined in| 7f688779_6b22_3c15_6514_97dec91c3c30
  197dc748_a445_1ef1_c0ca_67e4cc9589fd["validate()"]
  3a13db06_7756_8b88_8330_0d14f9140935 -->|calls| 197dc748_a445_1ef1_c0ca_67e4cc9589fd
  20ea4a11_aece_5926_4bf5_5da699da083d["_validate()"]
  3a13db06_7756_8b88_8330_0d14f9140935 -->|calls| 20ea4a11_aece_5926_4bf5_5da699da083d
  style 3a13db06_7756_8b88_8330_0d14f9140935 fill:#6366f1,stroke:#818cf8,color:#fff

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

Subdomains

Frequently Asked Questions

What does EmailStr() do?
EmailStr() is a function 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.
What does EmailStr() call?
EmailStr() calls 2 function(s): _validate, validate.

Analyze Your Own Codebase

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

Try Supermodel Free