You are given a Python validation library similar to Colander. A schema node can run multiple validators. Validators may raise validation errors, and all errors are aggregated into a structured dictionary through an asdict() method.
The current implementation has three failing test groups. Your task is to debug the code, identify the root causes, and implement fixes.
Requirements
-
Handle null or empty validation messages
-
Some validators produce
None
, an empty string, or lists containing null/empty messages.
-
Aggregation currently crashes when combining these messages.
-
Fix the aggregation logic so it filters invalid messages before combining them.
-
Real messages should still be preserved.
-
Handle nested validation errors correctly
-
Validators can be nested across multiple schema levels.
-
Errors from inner validations must be propagated and combined correctly in
asdict()
.
-
Nested structures may contain values such as
[None, 'must be positive']
.
-
The final output should not crash, should not include null messages, and should not lose valid child errors.
-
Make sequence serialization defaults consistent
-
During serialization, empty inputs and null-like values are currently handled differently.
-
For sequence fields, inputs such as
[]
and lists containing only null-like values should be treated consistently.
-
Defaults should be applied uniformly regardless of whether the sequence is empty or contains only null-like placeholders.
Explain how you would debug the failures and what code-level changes you would make.