Usage Analysis of rules class validators in the Yii data model, yiirules
This document describes the usage of the rules class validators in the Yii data model. We will share this with you for your reference. The details are as follows:
Public function rules () {return 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 to verify array ('birthday', 'match ', 'pattern' => '% ^ \ d {4} (\-| \/| \.) \ d {1, 2} \ 1 \ d {1, 2} $ % ', 'allowempty' => true, 'message' => 'birthday must be in the year-month-day' format '), // email: email format verification array ('user _ mail', 'email '), // url: URL format verification array ('user', 'url '), // unique: unique verification array ('username', 'unique', 'casesensitive '=> false, 'classname' => 'user ', 'message' => 'user name "{value}" already registered, please change '), // caseSensitive defines whether the case is sensitive // com Pare: Consistency Verification array ('repassword', 'compare', 'companyattribute '=> 'Password', 'message' =>' the passwords entered at the two locations are inconsistent '), // length: length verification // in: Verify that this property 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 the array ('verifycode', 'captcha ') displayed in the verification code, // type: verify whether the attribute type is the type specified by type. // file: verify whether a property receives a valid Upload file // default: Specify the default value of the property // exist: verify whether the property value exists in the Database // boolean: verify the boolean property value // date: Check whether this property describes a date, time, or date time // safe: the attribute flag is safe when values are assigned in batches. // Unsafe: the flag is insecure, so they cannot be assigned values in batches.