1 rules commonly used by Yii rules2 3 return [4 //must fill in5[' Email, username, password,agree,verifypassword,verifycode ', ' required '],6 7 //Check that the user name is duplicated8[' email ', ' unique ', ' message ' = ' user name occupied '],9 Ten //user input maximum character limit One[' Email, username ', ' length ', ' Max ' =>64], A - //limit user Minimum length and maximum length -[' 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 '] , the - //Limit password Minimum length and maximum length -[' 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 -[' email ', ' email ', ' message ' = ' Email ' format error '], + A //Check if the password entered by the user is the same at[' VerifyPassword ', ' compare ', ' compareattribute ' and ' password ', ' message ' = ' Please enter the confirmation password '], - - //Check whether the user agrees to the terms of the agreement -[' Agree ', ' required ', ' requiredvalue ' =true, ' message ' + ' Please confirm that you agree to the terms of the privacy Agreement '], - - //determine if it is a date format in[' Created ', ' Date ', ' format ' = ' yyyy/mm/dd/hh:mm:ss '], - to //determines whether the input character is included +[' Superuser ', ' in ', ' range ' = [0, 1]], - the //the regular validator: *[' Name ', ' match ', ' pattern ' = '/^[a-z0-9\-_]+$/'], $ Panax Notoginseng //Digital Validator: -[' id ', ' numerical ', ' min ' =>1, ' Max ' =>10, ' integeronly ' =true], the + //Type validation Integer,float,string,array,date,time,datetime A[' Created ', ' type ', ' datetime '], the + //File Validation: - [ $' filename ', $' File ', -' AllowEmpty ' =true, -' Types ' = ' zip, rar, xls, PDF, ppt ', the' Toolarge ' + ' pictures do not exceed 800K ' -],Wuyi the[' URL ', -' File ',//defined as file type Wu' AllowEmpty ' =true, -' Types ' = ' jpg,png,gif,doc,docx,pdf,xls,xlsx,zip,rar,ppt,pptx ',//types of uploaded files About' 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! ‘ -], -)
Rules commonly used by YII rules