2 ms·
> 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 reco
by elric 2y 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.