Skip to content

Composition #233

@ziflex

Description

@ziflex

Hi guys, thanks for this amazing library!

I wonder if there is a way how to extend predicates or compose a new one using a set of others.
Here is a use case:

interface User {
    id: string;
    email: string;
}

const assertUser = ow.create('User', ow.object.partialShape({
    id: ow.string.nonEmpty,
    email: ow.string.nonEmpty,
}))

interface Person extends User {
    firstName: string;
    lastName: string;
}

const assertPerson = ow.create('Person', ow.object.partialShape({
    id: ow.string.nonEmpty,
    email: ow.string.nonEmpty,
    firstName: ow.string.nonEmpty,
    lastName: ow.string.nonEmpty,
}))

I would love to be able to avoid code duplication.

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