Closed jordancrane-truework closed 5 months ago
@jordancrane-truework Hi. I think you made a mistake. Regexp digit is \d
not /d
. This code should work:
from pydantic_xml import BaseXmlModel, element
class TestXmlModel(BaseXmlModel, tag="Test"):
field: str = element(tag="Field", pattern=r"\d+")
TestXmlModel(field="1234")
@dapper91 Oops, you're correct, dumb mistake on my part - thanks for the correction. Unfortunately even with the correct regex I still get the same error.
@jordancrane-truework Hmm. That code works perfect on my side. Please, could you provide python, pydantic-xml, pydantic and pydantic-core versions you are using.
Given the following example code:
The following error occurs:
pydantic_xml.errors.ModelError: type chain is not supported
It works fine with other constraint types that I have tried (
max_length
,min_length
).