Skip to content

Discussion: Can oneOf be implemented? #151

@rubenferreira97

Description

@rubenferreira97

Currently is not possible to write a schema, where the given data must be valid against exactly one of the given subschemas.

I am almost certain that this was not implemented since it's hard to express on Typescript.

However, after some search I think it's possible to achieve a type "XOR" by adding never to the remaining properties (Don't know if it solves every problem though).

Playground from microsoft/TypeScript#14094:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions