How to use the runtypes.Intersect function in runtypes

To help you get started, we’ve selected a few runtypes examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hmil / rest.ts / test / fixtures / DTOs.ts View on Github external
});

export const TodoItemType = rt.Union(
    rt.Literal('housekeeping'),
    rt.Literal('work'),
    rt.Literal('shopping')
);

export const TodoItem = rt.Record({
    title: rt.String,
    done: rt.Boolean,
    type: TodoItemType
});


export const SavedTodoItem = rt.Intersect(
    TodoItem,
    rt.Record({
        id: rt.String
    })
);

export const SimpleMessage = rt.Record({
    message: rt.String
});

export const PathData = rt.Record({
    path: rt.String,
    kind: rt.String,
    id: rt.String
});