Converting circular structure to JSON can occur during validation in the Validator class in the isObject method during this check: if (JSON.stringify(props) === JSON.stringify({})) return true;. The problem occurs when an Entity has props that contains another Entity or an array of Entities because the entities contain _domainEvents, which is a circular ref.
A new utils function named stringify allows handling circular ref similar to JSON.stringify.
Fix
Converting circular structure to JSON
can occur during validation in theValidator
class in theisObject
method during this check:if (JSON.stringify(props) === JSON.stringify({})) return true;
. The problem occurs when anEntity
hasprops
that contains anotherEntity
or an array ofEntities
because the entities contain_domainEvents
, which is acircular ref
.A new
utils
function namedstringify
allows handlingcircular ref
similar toJSON.stringify
.issue
https://github.com/4lessandrodev/type-ddd/issues/414