Closed CD3 closed 9 years ago
thanks for this, I'm going to try to write up a quick test for this & will merge soon
Sounds good. Do you want me to write one? You just using py.test right?
Sure if you have time that'd be great
On Tue, Jun 9, 2015 at 3:02 PM, C.D. Clark III notifications@github.com wrote:
Sounds good. Do you want me to write one? You just using py.test right?
— Reply to this email directly or view it on GitHub https://github.com/sunlightlabs/validictory/pull/88#issuecomment-110465507 .
James Turk Labs Director | Sunlight Foundation http://www.sunlightfoundation.com/ 202-558-8723 | @JamesTurk https://twitter.com/jamesturk
[image: Sunlight Foundation] http://sunlightfoundation.com/
OK, I added two tests. One checks that validation does not fail when fast_fail is turned off an a type list is encountered (this is the error fixed by the previous commit), and the second tests that an error is raised and added to the MultipleValidationError that is raised.
thanks, looks great!
if a type is specified as a list, then the data should be validated against each element in the list and be considered valid if item succeeds. the validate_type function does this by catching exceptions with a try/except block until one schema validates.
however, if fast_fail is turned off, then exceptions are not thrown immediatly, they are instead placed in a list to be thrown later. this caused the loop through possible schemas to exit after the first schema, even if it was not valide. however, the first schema would still put an error in the _errors list if it was not valid.
so, if the first schema raised an exception, its exception would be placed in the esception list and the types loop would not catch it, exiting immediatly. then, even if a valid schema did exist at some point later in the list, the validate function would report an error.
this fix monitors the _errors list to handle the above situation correctly.