feat: add equals() to Price and Uuid Value Objects#48
Merged
jorge07 merged 1 commit intojorge07:masterfrom Feb 22, 2026
Merged
Conversation
D2.2 from Phase 2 roadmap. Violation: Price and Uuid-based identities had no equals() method. Reference equality (===) is always false for two separate instances representing the same value. Source: Evans (Blue Book), p. 98 — "Value objects should be testable for equality. [...] Use the fields of the object to determine equality." Fix: - Price.equals(other: Price): compares amount and currency - Uuid.equals(other: Uuid): compares toString() values (TransactionId inherits this via extension) Tests: added equals() coverage to Price.test.ts and new TransactionId.test.ts (also adds negative amount, non-numeric amount rejection tests for completeness)
jorge07
approved these changes
Feb 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Value Objects had no
equals()method. Comparing two instances representing the same value with===always returnsfalse(reference equality), making it impossible to express domain equality checks correctly.Source: Evans (Blue Book), p. 98 — "Value objects should be testable for equality. [...] Use the fields of the object to determine equality."
Fix
Price.equals(other: Price): boolean— comparesamountandcurrencyUuid.equals(other: Uuid): boolean— compares string representations;TransactionIdinherits this via extensionTests
Price.test.ts— addedequals()coverage (same, different amount, different currency) plus missing rejection tests (negative amount, non-numeric amount)TransactionId.test.ts— new file; covers same/different UUID equality, auto-generated uniqueness, and invalid UUID rejectionAll 23 tests pass.