The unique validator already does what (I think) you’re attempting to do. It only adds an error if it finds another record with the same attribute value but a different primary key.
I try to change a record (for example i’m going to change a text field for description) but I will not change the unique field. But the field has the same value as in database. So I will get the error. But I actually was not trying to change the unique field, was I?
So if I change the unique field the validator must work otherwise I dont need to valid it as I have not made changes at all.
I don’t understand. Are you saying you’re happy to have non-unique values for that attribute if the records already exist? Specifically, are you saying that non-unique values already exist in the database table?
Why not just allow the validator to run anyway? It will work correctly and the overhead will be negligible unless you’re running a huge number of updates.