Home > Article > Backend Development > Yii-data model-detailed explanation of rules class validator method, yii-rules_PHP tutorial
public function rules()
{
return array(
array( 'project_id, type_id, status_id, owner_id, requester_id,', 'numerical', 'integerOnly'=>true),
array('name', 'length', 'max'=>256),
array('description', 'length', 'max'=>2000),
array('create_time,create_user_id,update_user_id, update_time', 'safe'),
array('id, name, description, project_id, type_id, status_id, owner_id', 'on'=>'search'),
);
}
//required: required
array('title,content','required'),
//match: Regular expression verification
array('birthday', 'match', 'pattern'=>'%^d{4}(-|/|.)d{1,2} 1d{1,2}$%', 'allowEmpty'=>true, 'message'=>'Birthday must be in year-month-day format'),
//email: Email format verification
array('user_mail', 'email'),
//url: URL format verification
array('user', 'url'),
//unique: uniqueness verification
array('username', 'unique','caseSensitive'=>false,'className'=>'user','message'=>'username "{value}" has been registered, please replace'),
//caseSensitive defines whether case sensitivity
//compare: Consistency verification
array('repassword', 'compare', 'compareAttribute'=>'password','message'=>'The passwords entered in the two places are not consistent'),
//length: length verification
//in: Verify that this attribute value is in the list (specified by range).
//numerical: Verify that the value of this attribute is a number
//captcha: Verify that the attribute value is consistent with what is shown in the verification code
array('verifyCode','captcha'),
//type: Verify whether the type of the attribute is the type specified by type.
//file: Verify whether an attribute received a valid uploaded file
//default: attribute specifies the default value
//exist: Verify whether the attribute value exists in the database
//boolean: Verify Boolean attribute value
//date: Check whether this attribute describes a date, time or datetime
//safe: Property flag is safe for batch assignment.
//unsafe: Flags are unsafe, so they cannot be batch assigned.
yxmhero1989.blog.163.com/...61864/
Generally, Model::model()->method name