YII rules common validation Rule Memo _php Tutorial

Source: Internet
Author: User

YII rules common validation Rule memo


Record the rules validation rule that is more commonly used in Yii, and look back carefully.

return Array (//must fill in array (' email, username, password,agree,verifypassword,verifycode ', ' required '),//Check whether the user name is duplicated        Array (' email ', ' unique ', ' message ' = ' username occupied '),//user input maximum character limit of array (' email, username ', ' length ', ' Max ' =>64), Limit the user's minimum length and maximum length to array (' username ', ' length ', ' Max ' =>7, ' min ' =>2, ' toolong ' + ' username Please enter a length of 4-14 characters ', ' Tooshort ' + ' username Please enter the length of 2-7 words '),//Limit password minimum length and maximum length of array (' password ', ' length ', ' Max ' =>22, ' min ' =>6, ' toolong ' = = ' Password Please enter Length is 6-22 characters ', ' tooshort ' = ' = ' Password please input length of 6-22 characters '),//Determine whether the user input is the Mail array (' email ', ' email ', ' message ' = ' Mail format error '),//check Check whether the password entered by the user is the same as the array (' VerifyPassword ', ' compare ', ' compareattribute ' = ' password ', ' message ' = ' Please enter the confirmation password '),//check 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 the date format is Arra Y (' created ', ' Date ', ' format ' = ' yyyy/mm/dd/hh:mm:ss '),//Determine if the character containing the input is an array (' Superuser ', ' in ', ' range ' = Arra        Y (0, 1)),//Regular authenticator:    Array (' name ', ' match ', ' pattern ' = '/^[a-z0-9\-_]+$/'),//Digital Authenticator: Array (' ID ', ' numerical ', ' min ' =>1 , ' Max ' =>10, ' integeronly ' =>true),//type validation integer,float,string,array,date,time,datetime array (' C Reated ', ' type ', ' datetime '),//file Validation: Array (' filename ', ' file ', ' AllowEmpty ' =>true, ' types ' = ' zip, RAR, XL S, 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 ',//upload file type ' maxSize ' =>1024*1024*10,//upload size limit, Note that not the upload file size in php.ini ' toolarge ' + ' file is greater than 10M, upload failed! Please upload files less than 10M! '  ),);

Articles you may be interested in

    • Dedecms tips for Dedetag Engine Create File false Error resolution
    • Php method for verifying mailboxes, URLs, and IP addresses using the filter function
    • Unix/linux Common basic Command Graphic tutorial
    • PHP Extract the birthday date from the ID number and the function to verify whether it is a minor
    • JS get the code of the key, JS how to block the user's keys, JS get the user keys corresponding to the ASII code (compatible with all browsers)
    • Very useful PHP pop-up error warning function
    • Windows cannot start this hardware device because its configuration information (in the registry) is incomplete or corrupted. (Code 19) workaround
    • thinkphp Automatic validation and auto-fill Invalid workaround

http://www.bkjia.com/PHPjc/995121.html www.bkjia.com true http://www.bkjia.com/PHPjc/995121.html techarticle Yii Rules Common validation rule memo to the more commonly used rules validation rules in Yii record, looking back seriously. return Array (//must fill in the array (' email, username, passwor ...

  • 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.