Public Function Rules ()
{
return [
Must fill in
[' Email, username, password,agree,verifypassword,verifycode ', ' required '],
Check that the user name is duplicated
[' email ', ' unique ', ' message ' = ' user name occupied '],
User input maximum character limit
[' Email, username ', ' length ', ' Max ' =>64],
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 '] ,
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 '],
Check if the password entered by the user is the same
[' 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 consent to the terms of the privacy Agreement '],
Determine if it is a date format
[' Created ', ' Date ', ' format ' = ' yyyy/mm/dd/hh:mm:ss '],
Determines whether the input character is included
[' Superuser ', ' in ', ' range ' = = Array (0, 1)],
The regular validator:
[' Name ', ' match ', ' pattern ' = '/^[a-z0-9\-_]+$/'],
Digital Validator:
[' id ', ' numerical ', ' min ' =>1, ' Max ' =>10, ' integeronly ' =>true],
Type validation Integer,float,string,array,date,time,datetime
[' Created ', ' type ', ' datetime '],
File Validation:
[' filename ', ' file ', ' AllowEmpty ' =>true, ' types ' = ' zip, rar, xls, PDF, ppt ', ' toolarge ' + ' pictures do not exceed 800K '],
[' URL ',
' File ',//defined as file type
' AllowEmpty ' =>true,
' Types ' = ' jpg,png,gif,doc,docx,pdf,xls,xlsx,zip,rar,ppt,pptx ',//type of upload file
' MaxSize ' =>1024*1024*10,//upload size limit, note not php.ini upload file size
' Toolarge ' + ' file is larger than 10M, upload failed! Please upload files less than 10M! ‘
],
];
}
Yii2.0 Chinese Development Wizard--rules common rules