Common Yiirules rule examples and yiirules example _ PHP Tutorial

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.