You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Pydantic 2.x, the regex attribute for specifying regular expressions in the Field class has been removed, and you should use the pattern attribute instead. Here's how you can update your code:
from pydantic import BaseModel, Field, constr
class MyModel(BaseModel):
email: constr(regex=RE_EMAIL_PATTERN)
Bug
if you define a field like
The program when run gives the following exception:-
Current Behavior
just define a Field that has a regex defined
Expected behavior
it would be good to align with Pydantic and support the patten keyword argument
Environment
pydantic version: 2.5.2
pydantic-core version: 2.14.5
pydantic-core build: profile=release pgo=true
python version: 3.12.1 (main, Dec 10 2023, 13:40:31) [Clang 15.0.0 (clang-1500.0.40.1)]
platform: macOS-14.1.2-arm64-arm-64bit
related packages: fastapi-0.105.0 typing_extensions-4.9.0 pydantic-settings-2.1.0
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: