You should do your validation in a microflow (There is a validation message action). Within your microflow you can apply any logic you need and you can easily differentiate between different messages.
When the user hits save, your microflow should do the validation, and only commit the object if everything is valid. If not, it can just show the validation messages.
I am sure that this is explained in some learning paths. I would highly recommend to work through them. They are really good.
Check out the ‘Validation in microflows’ section in the rapid application developer learning path. It covers everything you’ve asked about I think. Here is the direct link to the section
https://gettingstarted.mendixcloud.com/link/module/95/lecture/770