How to add validation rules from database?

My fields and validation are stored in database. I have searched dynamic rules, add rules, custom validation and all but cannot find anything I can understand.

How to generate Rules and Validate user defined fields on the fly according to information store in db?

My model look like this

	public function rules()


		return array(

			array('FieldName, FieldType', 'required'),		

			array('Id, SortOrder', 'numerical', 'integerOnly'=>true),

			array('FieldName', 'length', 'max'=>255),

			array('FieldType', 'length', 'max'=>20),



Its should not be validating "FieldName" and "FieldType" but the actual record depending on its custom rules.

Will this work?


	 * @return array validation rules for model attributes.


	public function rules()


              1.Load rules from Db



              foreach record in db


                $arrayRules[] = array(record->FieldName, record->Rules),


              return $arrRules;


the nearest I found is this, but looks like its not solved :

Check this method: