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:
- Circular relations being marked as
.optional() so their values in the schema are not required.
- 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.
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:
.optional()so their values in the schema are not required..getDefaultValue()from the appropriate relation class.Need to decide if this is acceptable or a better approach can be recommended.