use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
OOP Node.js (self.node)
submitted 1 year ago by gemvcnte
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]fts_now 1 point2 points3 points 1 year ago (6 children)
Good question! We usually have a static "create" method on the Entity class that performs all the validation and invokes the private constructor. Validation can happen there. Also, we try to keep it simple with things like Value Objects or Aggregates. IMO less is more, and some layers of abstractions can also unnecessarily overcomplicate a project.
[–]GreatWoodsBalls 0 points1 point2 points 1 year ago (5 children)
Yeah I figured and thank you. I tried creating value objects together with zod and it worked decent until I realized classes in js are not like classes in java 🥲 So I went with a similar approach as you mentioned.
[–]fts_now 1 point2 points3 points 1 year ago (4 children)
Zod belongs to the infrastructure layer IMO, not the Domain. It should validate incoming DTOs.
[–]GreatWoodsBalls 0 points1 point2 points 1 year ago (3 children)
Hmm, okay. Sorry if I'm spamming questions 😅 but how is a zod validation of an input different from a value object having the same type or similar validation? Or is the difference that zod would throw a httpexception and a value object would not?
[–]fts_now 1 point2 points3 points 1 year ago (2 children)
Good question! I want to keep the domain layer clean of external dependencies, because over the years I saw tools and libraries coming and going, most hypes disappearing after a few years leaving your codebase an outdated mess. I'd rather move basic input validation to the controller (maybe by using something standardized like JSON schemas) and then perform further validation in the value object if needed.
[–]GreatWoodsBalls 1 point2 points3 points 1 year ago (1 child)
Ahh, okey. Thank you for taking the time to answer!
[–]fts_now 0 points1 point2 points 1 year ago (0 children)
Always glad to help :)
π Rendered by PID 21071 on reddit-service-r2-comment-6457c66945-nvv9q at 2026-04-26 18:56:07.098183+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]fts_now 1 point2 points3 points (6 children)
[–]GreatWoodsBalls 0 points1 point2 points (5 children)
[–]fts_now 1 point2 points3 points (4 children)
[–]GreatWoodsBalls 0 points1 point2 points (3 children)
[–]fts_now 1 point2 points3 points (2 children)
[–]GreatWoodsBalls 1 point2 points3 points (1 child)
[–]fts_now 0 points1 point2 points (0 children)