Can I use 'exists' as filter?

Hi, I must understand whether the email I am inserting appears in DB. I don't want the unique filter. I am developing a Personal Messages(PM) system, and I have to check whether the email of the addressant person is in DB. It can be done easily on controller level, but I wondered whether there is a way to do it at accessControl?

Do you mean filter or validator? And why unique validator doesn't work for you?

Sorry, I really meant a validator. Because I don't want it to be unique, but to exists. Therefore, I am not looking whether I have it in the database, but whether I don't have it. The email must correspond to an existing user, not to a "asfkjas@asdfh.bg" and so on…

I see. You can develop a ExistsValidator class or a method-based validator like the following:



function checkExists($attribute,$params)


{


    if(!self::model()->exists('email=?', array($this->$attribute)))


       $this->addError(...);


}