yii-Data Model-an explanation of the Rules class validator method

Source: Internet
Author: User

 Public functionrules () {return Array(        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: RequiredArray(' title,content ', ' required '),//match: Regular expression validationArray(' Birthday ', ' match ', ' pattern ' = '%^\d{4} ' (\-|\/|\.) \d{1,2}\1\d{1,2}$% ', ' allowempty ' =true, ' message ' = ' birthday must be ' year-month-day format '),//Email: email Format VerificationArray(' User_mail ', ' email '),//url:url Format VerificationArray(' user ', ' url '),//Unique : Uniqueness verificationArray(' username ', ' unique ', ' casesensitive ' =false, ' className ' = ' user ', ' message ' + ' username ' {value} ' has been registered, please replace '),//casesensitive defines case sensitivity//compare: Conformance verificationArray(' Repassword ', ' compare ', ' compareattribute ' = ' password ', ' message ' = ' The password entered in the two is inconsistent '),//Length: Validation//in: Verify that this property value is in the list (specified by range). Numerical: Verify that the value of this property is a number//captcha: Verify that the property value is consistent with the display in the Verification codeArray(' Verifycode ', ' captcha '),//Type : Verify that the type of the property is of type specified by type.//file: Verifies whether a property receives a valid upload file//default: property specifies the default value//exist: Verify that the property value exists in the database//boolean: Verify Boolean property value//date: Verifies whether this property describes a date, time, or datetime//safe: The property flag is safe for bulk assignment. Unsafe: Flags are unsafe, so they cannot be assigned in bulk. 

return Array(    //must fill in    Array(' email, username, password,agree,verifypassword,verifycode ', ' required '),//Check that the user name is duplicated    Array(' email ', ' unique ', ' message ' = ' username occupied '),//user input maximum character limit    Array(' Email, username ', ' length ', ' Max ' =>64),//limit user Minimum length and maximum length    Array(' username ', ' length ', ' Max ' =>7, ' min ' =>2, ' toolong ' + ' username Please enter a length of 4-14 characters ', ' tooshort ' + ' username Please enter a length of 2-7 words ') ,//Limit password Minimum length and maximum length    Array(' Password ', ' length ', ' Max ' =>22, ' min ' =>6, ' toolong ' + ' password Please enter a length of 6-22 characters ', ' tooshort ' and ' = ' password Please enter a length of 6-22 characters ' ),//determine if the user is entering a message    Array(' email ', ' email ', ' message ' = ' Email ' format error '),//Check if the password entered by the user is the same    Array(' VerifyPassword ', ' compare ', ' compareattribute ' = ' password ', ' message ' = ' Please enter the confirmation password '),//Check whether the user agrees to the terms of the agreement    Array(' agree ', ' required ', ' requiredvalue ' =true, ' message ' + ' please confirm your consent to the terms of the Privacy Agreement '),//determine if it is a date format    Array(' Created ', ' Date ', ' format ' = ' yyyy/mm/dd/hh:mm:ss '),//determines whether the input character is included    Array(' Superuser ', ' in ', ' range ' =Array(0, 1)),//the regular validator:    Array(' name ', ' match ', ' pattern ' = '/^[a-z0-9\-_]+$/'),//Digital Validator:    Array(' id ', ' numerical ', ' min ' =>1, ' Max ' =>10, ' integeronly ' =true),//Type validation Integer,float,string,array,date,time,datetime    Array(' Created ', ' type ', ' DateTime '),//File Validation:    Array(' filename ', ' file ', ' allowempty ' =true, ' types ' = ' zip, rar, xls, PDF, ppt ', ' toolarge ' + ' pictures do not exceed 800K '),Array(' url ', ' file ',//defined as file type' AllowEmpty ' =true, ' types ' = ' jpg,png,gif,doc,docx,pdf,xls,xlsx,zip,rar,ppt,pptx ',//types of uploaded files' MaxSize ' =>1024*1024*10,//Upload size limit, note not upload file size in php.ini' Toolarge ' + ' file is larger than 10M, upload failed! Please upload files less than 10M! ‘      ),);

yii-Data Model-an explanation of the Rules class validator method

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.