-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X
Description
Bug
Pydantic does not accept pre-compiled regular expression Pattern objects as valid values for Pattern-typed fields. Linked to issue #1211 . I'll create a pull request.
By the way, I've just discovered Pydantic and it blows my mind. Incredible work, thank you!
Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":
pydantic version: 1.4
pydantic compiled: False
install path: C:\Users\agregory\.virtualenvs\Diasemi\Lib\site-packages\pydantic
python version: 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)]
platform: Windows-10-10.0.17134-SP0
optional deps. installed: []
import pydantic
import re
import typing
class Amodel(pydantic.BaseModel):
name: typing.Pattern
@pydantic.validator('name', pre=True)
def compile_insensitive(cls, value: str) -> typing.Pattern:
return re.compile(value, re.IGNORECASE)
x = Amodel(name='Something')Metadata
Metadata
Assignees
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X