Contional Validation

Hello all,

I just started with Yii and I have the below situation.

My Model has a field, username, and this field can be a phone number or an email.

There is any native way to do this kind of validation ?

Thank you very much!

Hi pvk,

Do you want your ‘username’ to be ALWAYS a phone number or an email?

If yes, then a function based validation will be the answer.

Or if you want it be a phone number in some situation and an email in another, then using "scenario" to distinguish those situations will be the answer.

Hi softark,

Thanks for your answer.

I just ckecked it and i used a custom function to validate it and worked fine!

My case was the ‘username’ is ALWAYS a phone number or an email.