diff --git a/docs/advanced/combine-pydantic-and-semver.rst b/docs/advanced/combine-pydantic-and-semver.rst index c7566e12..975fb418 100644 --- a/docs/advanced/combine-pydantic-and-semver.rst +++ b/docs/advanced/combine-pydantic-and-semver.rst @@ -9,7 +9,22 @@ According to its homepage, `Pydantic `_ "enforces type hints at runtime, and provides user friendly errors when data is invalid." -To work with Pydantic>2.0, use the following steps: +If you are working with Pydantic>2.0 and pydantic-extra-types>=2.10.5 use the built in `SemanticVersion` type, which wraps the :class:`Version ` class. + + .. code-block:: python + + from pydantic import BaseModel + from pydantic_extra_types.semantic_version import SemanticVersion + + class appVersion(BaseModel): + version: SemanticVersion + + app_version = appVersion(version="1.2.3") + + print(app_version.version) + # > 1.2.3 + +To work with Pydantic>2.0 and without pydantic-extra-types use the following example to define your own type: 1. Derive a new class from :class:`~semver.version.Version` pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy