validation rule with special conditions

Im having trouble with Yii1 validation. I have listbox with contact types and i want email validation to work only when contact via email is choosed. So Im using custom rule to check if email is selected:

public function customEmailValidation($attribute, $params)

{

if(!$this->hasErrors())


{


    if($this->contact_type == 2)


    {


        if($this->attribute == "") $this->addError($attribute, "Enter email address");


    }


}

}

But after that I want to use second rule to check if email format is good, how i can achieve it? In main rules i can check it by this:

[‘email’, ‘email’, ‘message’ => ‘wrong email format’],

but how i can check it only when $this->contact_type == 2 ? I need to write custom rule also and I need to write regex to check email format? Or somehow i can use main validation rules in custom validations?

Thank you.