ostrowr / ts-json-validator

Let JSON play nicely with Typescript
MIT License
342 stars 7 forks source link

Support oneOf #4

Open ostrowr opened 4 years ago

ostrowr commented 4 years ago

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

EdwardDrapkin commented 4 years ago

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.

ostrowr commented 4 years ago

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