Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Intersect withConstraint does not work anymore in v7 #488

@jume-dev

Description

@jume-dev

Hi there,
currently trying to migrate my project from v6 to v7, but I struggle to make the snippet below work. Is this a bug, or do I do something wrong?

const Header = Object({ name: String })
const Body = Object({ content: String })

const HelloMessage = Intersect(Header, Body)
  .withConstraint((m) => m.name === 'message' && m.content === 'Hello')

This code snippet is wrong, because m only consist of the Body and not the Header anymore. In v6 this code did work.

If this is indeed is wrong, then please guide me on how I would achieve to create a constraint on a intersection.

EDIT: If i switch Header and Body in the Intersect, I can access the Header in the constraint but not the Body anymore

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions