Dict will pass the LIST_OF check
derick0823 opened this issue · 5 comments
class BroadcastSpec:
recipient_tags = Checker(
[LIST_OF], LIST_OF=INT)
not_ok_data = {
"recipient_tags":{}
}
is_valid = validate_data_spec(not_ok_data, BroadcastSpec) // returns True, but expected False
I can use [LIST, LIST_OF] to check if recipient_tags is a list,
but LIST_OF should check if recipient_tags is a list type IMAO.
The "list" here stands for "iterable" or a "collection".
We should probably change the name or add some parameter to make it configurable.
On second thought, I would suggest keeping LIST_OF
specifically for the Python list
class as it's literally hinting to the code reader that it must be a list
.
Besides, in the next release, a new check, maybe named FOR_EACH
/EACH_OF
, will be available to support this kind of iterating validation.
Any suggestion?
good idea, then we may want to add more checkers for other builtin types.
Maybe adding a warning message to current version before moving to next release? I would be happy to see LIST_OF is distinguishable from other iterable classes, but it could be a big change for users.