Open pauljamescleary opened 6 years ago
Actually unsure if we should do this or not tbh. Happy to get other people's thoughts on it.
Assuming all data was in a single JDBC database, this seems like the best approach. However, I have built systems with heterogeneous backing stores where this would not be possible.
Also, unless I have other ways to demonstrate dependent validations (i.e. validations requiring external data), then these serve as a good use case for those.
The way we check if something exists, or is unique, is done via Validations.
The correct way to do this in a SQL db application is to enforce those invariants in the data base using unique constraints.
Consider using http://tpolecat.github.io/doobie/docs/09-Error-Handling.html as a guide for handling these kinds of exceptions.