ostrowr/ts-json-validator

Support oneOf

ostrowr opened this issue · 2 comments

This supports anyOf/allOf fine, but supporting oneOf with strict type definitions will be tricky.

I haven't had time to dive into how you've implemented this library, so I haven't quite gotten to the point where I can open a PR, but I did figure out how to match exactly one of two given types in TS. Here's the Playground Link, it's a fat abuse of conditional types, but it demonstrably works... however, I don't know if the way it works is compatible with how you've implemented this library. That's a problem for another night.

Nice! I'll take a look this weekend and will hopefully get something like this in.