Skip to content

Commit

Permalink
Updated migration.md to add description of how to push down Field con…
Browse files Browse the repository at this point in the history
…straints to generics (#7751)
  • Loading branch information
NickG123 committed Oct 16, 2023
1 parent cde930f commit caf8482
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/migration.md
Expand Up @@ -170,6 +170,8 @@ The following properties have been removed from or changed in `Field`:
- `regex` (use `pattern` instead)
- `final` (use the `typing.Final` type hint instead)

Field constraints are no longer automatically pushed down to the parameters of generics. For example, you can no longer validate every element of a list matches a regex by providing `my_list: list[str] = Field(pattern=".*")`. Instead, use `typing.Annotated` to provide an annotation on the `str` itself: `my_list: list[Annotated[str, Field(pattern=".*")]]`

* [TODO: Need to document any other backwards-incompatible changes to `pydantic.Field`]


Expand Down

0 comments on commit caf8482

Please sign in to comment.