Top level API should be ideally similar to form/serializer, but it should be informed by a "second level" API which is purely functional.
I have something like this in my head:
# Read mode
a = Adapter()
data = a.adapt(initial={'instance': model_instance})
# Write mode
a = Adapter()
data = a.adapt(initial={'instance': model_instance}, data=request.data)
processed_data, errors = a.validate(data)
assert not errors
output = a.process(processed_data)
assert output['instance'] == model_instance
Note that no step needs to use a.blah for any blah except the structure of a.
Top level API should be ideally similar to form/serializer, but it should be informed by a "second level" API which is purely functional.
I have something like this in my head:
Note that no step needs to use
a.blahfor any blah except the structure ofa.