Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Manage wrong data type with unknown!=EXCLUDE #857
Jun 27, 2018
Jun 27, 2018
Hold this. It is a bit more complicated than I first thought.
It is not only the about the
Current approach is to iterate on fields and get keys from input data. If data has no get method, then
There are a few issues with this:
I added two commits showing two different approaches to this.
The first catches the
The second checks the type of
This reveals underlying design issues. It is not the simple change I thought. (And I came there while trying to tackle #851...)
In fact, the whole wrong data type case management is smelly from the start:
errors = self.get_errors(index=index) msg = field_obj.error_messages['type'].format( input=data, input_type=data.__class__.__name__, ) self.error_field_names = [SCHEMA] errors = self.get_errors() errors.setdefault(SCHEMA, ).append(msg)
We're trying to fit a schema error in a mechanism that was meant for field errors. And the logic here is a bit twisted: the first call to
This looks quite like a WWdD issue...
I agree that it's awkward right now. We should come up with a solution to configure both "invalid type" and "unknown field" (#852) error messages on the Schema class.
Yeah, it's not ideal. Either