There are a lot of libraries in the ecosystem that seek to do this kind of thing. I’ve even written my own which works with XML and JSON, and in theory any kind of input data. I even originally tried to get XML parsing / validating working with ecto custom types but it was a non starter.
I don’t think retrofitting more general data casting capabilities into ecto really makes sense because it’s a stable lib used by a lot of people and it was really designed with db tables and webforms in mind. It would likely be a big change and it’s not clear what the benefit would be.