Yii rules common verification rules memo
Record the common rules verification rules in Yii.
Return array (// you must enter array ('email, username, password, agree, verifyPassword, verifycode', 'required'), // check whether the username already exists in array ('mail ', 'unique', 'message' => 'username occupied '), // maximum character limit for user input array ('email, username', 'length ', 'max '=> 64), // restrict the minimum length and maximum length of the user array ('username', 'length', 'max' => 7, 'Min' => 2, 'toolong' => 'user name must be 4-14 characters long ', 'tooshort' => 'user name must be 2-7 characters long '), // restrict the minimum length and maximum length of the password array ('Password', 'length', 'max '=> 22 ,' Min' => 6, 'toolong' => 'enter a password with a length of 6 to 22 characters, 'tooshort '=> 'enter a password with a length of 6 to 22 characters '), // determine whether the email you entered is an array ('email ', 'email', 'message' => 'email format error '), // check whether the password entered by the user is the same array ('verifypassword', 'compare', 'compareattribute' => 'Password ', 'message' => 'Enter the password again '), // check whether the user agrees to the terms of the agreement array ('agree', 'required', 'requiredvalue '=> true, 'message' => 'Confirm that you agree to the privacy agreement clause '), // determine whether the date format is array ('created', 'date ', 'format' => 'yyyy/MM/dd/HH: mm: s S '), // determine whether to include 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, xls, pdf, ppt ', 'toolarge' => 'image Do not exceed KB), array ('url', 'file', // is defined as 'allowempty '=> true, 'types' => 'jpg, png, gif, doc, docx, pdf, xls, xlsx, zip, rar, ppt, pptx, // type of the uploaded file 'maxsize' => 1024*1024*10, // upload size limit. 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! '),);Articles you may be interested in
- Solution to the DedeTag Engine Create File False error in dedeCMS
- Php uses the filter function to verify the mailbox, url, and IP address
- Graphic tutorial on common basic commands in Unix/Linux
- Php extracts the birthday date from the ID card number and verifies whether it is a minor.
- JS obtains the key code, how Js shields users' keys, and Js obtains the ASII code corresponding to users' keys (compatible with all browsers)
- Very practical php pop-up error warning function
- Windows cannot start the hardware device because its configuration information (in the Registry) is incomplete or damaged. (Code 19) Solution
- Thinkphp automatic verification and automatic filling are invalid Solutions