Hacker News new | ask | show | jobs
by elric 636 days ago
> There's no good way to prevent a user from creating the record with an invalid date

That is factually incorrect.

You can do all of that validation in a record constructor, much like in a normal Java class constructor. There's a difference in syntax: you don't need to repeat the constructor arguments in parantheses, and don't have to perform the assignments yourself. These are tailored specifically for easy validation.