Usage Analysis of rules class validators in the Yii data model, yiirules

Source: Internet
Author: User

Usage Analysis of rules class validators in the Yii data model, yiirules

This document describes the usage of the rules class validators in the Yii data model. We will share this with you for your reference. The details are as follows:

Public function rules () {return 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: required Array ('title, content', 'required'), // match: Regular Expression to verify array ('birthday', 'match ', 'pattern' => '% ^ \ d {4} (\-| \/| \.) \ d {1, 2} \ 1 \ d {1, 2} $ % ', 'allowempty' => true, 'message' => 'birthday must be in the year-month-day' format '), // email: email format verification array ('user _ mail', 'email '), // url: URL format verification array ('user', 'url '), // unique: unique verification array ('username', 'unique', 'casesensitive '=> false, 'classname' => 'user ', 'message' => 'user name "{value}" already registered, please change '), // caseSensitive defines whether the case is sensitive // com Pare: Consistency Verification array ('repassword', 'compare', 'companyattribute '=> 'Password', 'message' =>' the passwords entered at the two locations are inconsistent '), // length: length verification // in: Verify that this property value is in the list (specified by range ). // Numerical: Verify that the value of this attribute is a number // captcha: Verify that the attribute value is consistent with the array ('verifycode', 'captcha ') displayed in the verification code, // type: verify whether the attribute type is the type specified by type. // file: verify whether a property receives a valid Upload file // default: Specify the default value of the property // exist: verify whether the property value exists in the Database // boolean: verify the boolean property value // date: Check whether this property describes a date, time, or date time // safe: the attribute flag is safe when values are assigned in batches. // Unsafe: the flag is insecure, so they cannot be assigned values in batches.

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.