Compatibility layer for pydantic v1/v2.