I may be misunderstanding, but it seems like the first one would pass when the user ID was the same and fail all other times. The compare validator should be successful when the attribute matches the specified value.
I was so sure, that this works exactly opposite way – throws error, if compared values are not equal.
I have never worked with CCompareValidator before and I assumed (from logical point of view only), that it works exactly the same as other validators.
For example. If we use CRequiredValidator, we say (again – logical point of view), that an attribute should be required. And validator throws error, when required attribute is not present (the opposite way). The same with others. We say, that attribute should be numeric or that string should have certain length at most and proper validator throws error message, when attribute isn’t numeric or when string hasn’t got length, that it should have.
And here comes compare validator. We say, that two values should be equal and it throws message, when they are equal (the right way, not the the opposite one). I got confused with that.
EDIT: I’ve asked some of my dev-friends, what is their first feeling and all of them reacted the same way, as I did – compare validator should throw an error, if two compared values are not equal.
I think you’re still misunderstanding it. The compare validator does throw an error if the two values are different (as you expect), but in your specific scenario, you wanted the validator to throw an error when the values were the same, because the user should only be able to edit other user records.