爱程序网

Yii CModel中rules验证规则[转]

来源: 阅读:

 

array(array(‘username’, ‘required’), array(‘username’, ‘length’, ‘min’=>3, ‘max’=>12), array(‘password’, ‘compare’, ‘compareAttribute’=>’password2′, ‘on’=>’register’), array(‘password’, ‘authenticate’, ‘on’=>’login’),  array(‘Price’,’numerical’, ‘integerOnly’=>true),);public function rules(){  return array(      array(‘title, content, status’, ‘required’),      array(‘title’, ‘length’, ‘max’=>128),      array(‘status’, ‘in’, ‘range’=>array(1,2,3)),      array(‘tags’, ‘match’, ‘pattern’=>’/^[ws,]+$/’,          ‘message’=>’Tags can only contain word characters.’),      array(‘tags’, ‘normalizeTags’),      array(‘title, status’, ‘safe’, ‘on’=>’search’),  );}