In: yii
1 二 2011?boolean: Alias of CBooleanValidator, 只有true和 false
?captcha: Alias of CCaptchaValidator, 验证码验证
?compare: Alias of CCompareValidator, 对比表单里面的属性或者常量
?email: Alias of CEmailValidator, 确认是个正确的e-mail 地址
?default: Alias of CDefaultVAlidator, 按照默认值设置
?exist: Alias of CExistValidator, 确定可以从表的字段里面找到in the specified table column
?file: Alias of CFileValidator, 确定属性包括上传文件名an uploaded file,简单说就是确认有上传文件
?filter: Alias of CFilterValidator, transforming the attribute with a filter
?in: Alias of CRangeValidator, 在指定的列表里面存在
?length: Alias of CStringValidator, 大小限制
?match: Alias of CRegularExpressionValidator, 确定数据匹配一个正则表达式
?numerical: Alias of CNumberValidator, 确定是个有效数字
?required: Alias of CRequiredValidator, 确定不能为空
?type: Alias of CTypeValidator,确定属性是个特定的类型
?unique: Alias of CUniqueValidator, 确定字段在表里的列是唯一字段
?url: Alias of CUrlValidator, 确定是个正确的url
下面是个例子
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('create_user_id, update_user_id', 'numerical','integerO
nly'=>true),
array('name', 'length', 'max'=>128),
array('create_time, update_time', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, name, description, create_time, create_user_id,
update_time, update_user_id', 'safe', 'on'=>'search'),
array('name', 'required'),
);
}
By saving
QK31欢迎你的到来.