Examples of common Yiirules rules and yiirules rules. Examples of common Yiirules rules. For your reference, the details are as follows: publicfunctionrules () {returnarray (examples of common rules required for Yii rules and examples of yiirules
This article describes common rules of Yii rules. We will share this with you for your reference. The details are as follows:
Public function rules () {return array (// you must enter array ('email, username, password, agree, verifyPassword, verifycode', 'required '), // check whether the username is repeated array ('email ', 'Unique', 'message' => 'username occupied '), // array ('email, username', 'length', 'Max '=> 64 ), // restrict the minimum length and maximum length of an array ('username', 'length', 'Max '=> 7, 'min' => 2, 'toolong' => 'User name, please enter a length of 4-14 characters ', 'tooshort' => 'User name, please enter a length of 2-7 characters '), // restrict the minimum length and maximum length of the password array ('password ', 'Length', 'Max' => 22, 'min' => 6, 'toolong' => 'Enter a length of 6-22 characters for the password ', 'tooshort '=> 'Password, please enter a length of 6-22 characters'), // Determine whether the user entered an email array ('email ', 'Email ', 'message' => 'mailbox format error'), // check whether the password entered by the user is the same array ('verifypassword', 'Company ', 'areas attribute' => 'password', 'message' => 'Enter the confirm password'), // check whether the user agrees to the terms of the agreement array ('agree ', 'requestred', 'requiredvalue '=> true, 'message' => 'Confirm that you agree to the privacy agreement clause'), // Determine whether the date format is array ('created ', 'date', 'form At '=> 'yyyy/MM/dd/HH: mm: SS'), // determines whether the input character array ('superuser', 'in ', 'range' => array (0, 1), // regular expression validators: array ('name', 'match ', 'pattern' => '/^ [a-z0-9 \-_] + $/'), // number validators: array ('id', 'numerical ', 'Min' => 1, 'Max '=> 10, 'integeronly' => true), // type verification integer, float, string, array, date, time, datetime array ('created ', 'type', 'datetime'), // file verification: array ('filename', 'file', 'allowempty' => true, 'types' => 'zip, rar, xl S, pdf, ppt ', 'toolarge' => 'image cannot exceed 800k'), array ('URL', 'file ', // the file type is 'allowempty '=> true, 'types' => 'jpg, png, gif, doc, docx, pdf, xls, xlsx, zip, rar, ppt, pptx, // The type of the file to be uploaded 'maxsize' => 1024*1024*10, // the size limit of the file to be uploaded. Note that it is not php. the upload file size in ini is 'toolarge' => 'the file size is greater than 10 MB. Upload failed! Upload a file smaller than 10 MB! '),}); $ News = new news ('search'); // search Association rules