Skip to content

Non-nullable self-referencing relations #318

Description

@kettanaito

It is currently impossible to provide a self-referencing object(s) to Zod (I believe any schema library) as it will attempt to crawl it deeply and end up stuck in an infinite loop. Currently, this is circumvented by:

  1. Circular relations being marked as .optional() so their values in the schema are not required.
  2. All relations are detected when sanitizing and replaced with .getDefaultValue() from the appropriate relation class.

Need to decide if this is acceptable or a better approach can be recommended.

  • Sucks interfering with the user-defined schema. Some relations may be required but there's no way to describe that.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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