Would it be possible to pydantic-xml to output the line number in the XML source where a validation error occurred? For complex structures, this would help quite a bit.
For example:
from textwrap import dedent
from typing import List
from pydantic_xml import BaseXmlModel, attr, element
class Company(BaseXmlModel):
website: List[str] = element()
foo: int = element()
print(Company.from_xml(dedent(
"""
<Company>
<website>http://www.spacex.com</website>
<website>http://www.spacey.com</website>
<website>http://www.spacez.com</website>
<acfoo>This is not a number.</foo>
</Company>
"""
)))
produces
pydantic.error_wrappers.ValidationError: 1 validation error for Company
foo
value is not a valid integer (type=type_error.integer)
I'd like to see something like:
pydantic.error_wrappers.ValidationError: 1 validation error for Company
<input>, line 5: foo
value is not a valid integer (type=type_error.integer)
Would it be possible to pydantic-xml to output the line number in the XML source where a validation error occurred? For complex structures, this would help quite a bit.
For example:
produces
I'd like to see something like: