New API
Bobronium opened this issue · 0 comments
Bobronium commented
Let's discuss new vaa
api here.
Previously discussed:
- Make errors list of ErrorObj (Should we make it raisable?);
- Drop special types for validators in favor of functions and typing.NamedTuple. (done in #3)
I also suggest to:
- drop
is_valid
property and threat data as valid if no errors returned; - rename cleaned_data to data (cause it shorter) and just assume that is valid (still not sure about this).
New api example:
validator = vaa.get_from(some_scheme)
some_data = {'a': 1}
result = validator(some_data)
result.data
result.errors
# or
data, errors = validator(some_data)
if errors: # not valid
...
To think about:
- raising exception on errors?
- if we return errors and data is valid, should we return errors as a empty list or as
None
(same goes for data)?