ssangervasi / narrow-minded

Easy typeof validations with sophisticated TypeScript inference
https://www.harmless.dev/narrow-minded/
MIT License
3 stars 0 forks source link

Report which key or value caused the narrow to fail #3

Open ssangervasi opened 1 month ago

ssangervasi commented 1 month ago

It can be tricky to develop a narrow schema for a large JSON, especially one that has optional keys. It would be helpful if when narrow returns false there was a way to find out which type comparison failed. I'd mainly use this while debugging, but there may be other runtime use cases.

(Example: I've run into this a bunch while parsing RSS feeds)

ssangervasi commented 1 month ago

I have a branch where I've tried creating a whole generic traverse & object diff algorithm. A thorough nested diff would be great, but so far the complexity is maybe not worth it.