I am trying to add a validation to my entity disallowing the user to enter duplicate entries (based on some fields combination).
For this, I have created an entity listener and implemented the 2 methods onBeforeInsert() and onBeforeUpdate(), which read existing data from the database.
Based on that, I want to display an error message to the user if he is trying to enter duplicate info.
What is the best way to do this? Could you please share by providing some pseudo-code or an example?
I have read some related questions on the forum as well as the part related to Exception Handling in the guide, but couldn’t really manage to understand where to define the exception and how to call it, use it and throw it.
Your usual help is highly appreciated.