Closed GuillaumeDesforges closed 1 year ago
@GuillaumeDesforges Hi.
If your document may contain extra fields you should use ordered
search mode:
class Customer(BaseXmlModel, tag="Customer", search_mode='ordered'):
id: str | None = element()
name: str = element()
More details here
Thanks for the quick and effective reply, this fixerd the issue!
from pydantic_xml import BaseXmlModel, attr, element
from pydantic_xml.element.element import SearchMode
class Customer(
BaseXmlModel,
tag="Customer",
search_mode=SearchMode.ORDERED,
):
id: str | None = element()
name: str = element()
In fact, SearchMode.UNORDERED
is even better in my case
With a simple model:
this test fails
with error
versions: