Suppose we have following Typescript types:
type Parent = { mode: "A", a: string } | { mode: "B", b1: string, b2: Parent } | { mode : "C", c1: number, c2: Parent }
type Child = Parent & { x: string, y: number }
It's very easy to construct validation schemata for these types by means of io-ts https://github.com/gcanti/io-ts npm-package, but integration with NestJS for io-ts is not supported
So it's seems that it's necessary to use AJV validation. Nestjs provides capability of validation piping using AJV via associated json-schema by means of this npm-package https://www.npmjs.com/package/nestjs-ajv-glue
There is good tool named JSONSchemaType which provides mechanism for coupling Typescript type and associated AJV schema. But also seems that AJV validator does not support nested unions and intersections https://github.com/ajv-validator/ajv/issues/1302
So it's seems that it's necessary to write independent schemas and Typescript declarations which causes code duplication. Ok. But AJV itself does not provide good capabilities for unions, forcing distribute all possible union combinations into one top-level oneOf definition
So question - are there powerful Typescript-aware validation libraries compatible with NestJS? Goal is declare object schema ONE TIME in code in any non-redundant way and get automatically underlying Typescript type and appropriate runtime-validator.
All these features are supported in io-ts, but it does not work with NestJS validation pipes :(