Multiple date validation in rules()

Hi,

I have a form which submits a date and I’m using the CJuiDatePicker plugin. It works fine without validation, however, I would like to validate the input and allow the user to submit multiple formats: a year(YYYY); a year and month (YYYY-MM); or a full date (YYYY-MM-DD). I know i could use regular expressions, but don’t know where to place it in the model.

I have no problem with the form, I only want to know how to validate the input.

I’m a little new to Yii, so i need your help. :)

Thanks!

Benjie

Hi,

example




public function rules()

{

	// NOTE: you should only define rules for those attributes that

	// will receive user inputs.

	return array(

		array('name','match','pattern'=>'/^([a-zA-Z0-9_-\s])+$/'),			

	);

}



Thanks

Aruna