17 ms·
Specifically I use pydantic for validation, so yes, I expect pydantic to iterate over a list of 10000 elements and verify these are all ints.
by xarope 5y ago
Specifically I use pydantic for validation, so yes, I expect pydantic to iterate over a list of 10000 elements and verify these are all ints.
- matsemann 5y agoYeah, not doing that when using typescript is leading to so many bugs. Yes the compiler is happy, but you will get a runtime error as the json decoding converted it to a string, not the expected number type being passed around. So add in a second step that verifies that the decoded json actually matches the type and fail fast. One thing I liked about Elm was the decoders, a bit hassle to write but made it so easy catching bugs when backend and frontend people weren't on the same page.
- nerdponx 5y agoIt needs to be configurable IMO, but yeah for small lists I would rather loop and check than not check at all. However doing this for arbitrary iterables is impossible, because the iterable might be lazy or infinite. In that case maybe the best option is to wrap the iterable with something that would validate each element as it came off of the iterator that is produced from the iterable.