I have a Rails app (Postgres) and I want to add validation based on multiple parameters.. E.g.
if
Object.column1 & Object.column2 are NOT unique => reject new entry.
but if
Object.column1 IS not unique BUT Object.column2 for duplicate entry is different => accept new entry
What would be the best way to do that?
You can add a scope to your uniqueness constraint. It will then only check if the whole set of columns is unique.
Please refer to the documentation for more information.