Open shreddish opened 4 months ago
Deep equality checks are generally preferred for comparing value objects because they ensure that two objects are considered equal if they have the same value, regardless of whether they are different instances. In your case, comparing the internal UniqueEntityID
of the value objects for equality seems like the correct approach. This way, you ensure a more accurate comparison based on the underlying data, rather than the object references. Let me know if you find a solution that works better for your use case!
Because value objects use shallow object equality calling
equals
on the ID value object will always fail. This requires you to access the UniqueEntityID inside the value object prop and calling theequals
on that.CommentId.value.equals(SomeOtherCommentId.value)
vsCommentId.equals(SomeOtherCommentId
(will always fail)should we just be adding deep equality instead of shallow equality to the value object equality checks?