Examples of common Yii rules and 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