国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 PHP開發(fā) Analysis on usage of rules class validator in Yii data model

Analysis on usage of rules class validator in Yii data model

Dec 30, 2016 pm 02:43 PM

本文實(shí)例講述了Yii數(shù)據(jù)模型中rules類驗(yàn)證器用法。分享給大家供大家參考,具體如下:

public function rules()
{
  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: 必填
array('title,content','required'),
//match: 正則表達(dá)式驗(yàn)證
array('birthday', 'match', 'pattern'=>'%^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$%', 'allowEmpty'=>true, 'message'=>'生日必須是年-月-日格式'),
//email:郵箱格式驗(yàn)證
array('user_mail', 'email'),
//url:URL格式驗(yàn)證
array('user', 'url'),
//unique:唯一性驗(yàn)證
array('username', 'unique','caseSensitive'=>false,'className'=>'user','message'=>'用戶名"{value}"已經(jīng)被注冊(cè),請(qǐng)更換'),
//caseSensitive 定義大小寫是否敏感
//compare:一致性驗(yàn)證
array('repassword', 'compare', 'compareAttribute'=>'password','message'=>'兩處輸入的密碼并不一致'),
//length:長(zhǎng)度驗(yàn)證
//in: 驗(yàn)證此屬性值在列表之中(通過(guò)range指定)。
//numerical: 驗(yàn)證此屬性的值是一個(gè)數(shù)字
//captcha: 驗(yàn)證屬性值和驗(yàn)證碼中顯示的一致
array('verifyCode','captcha'),
//type: 驗(yàn)證屬性的類型是否為type所指定的類型.
//file: 驗(yàn)證一個(gè)屬性是否接收到一個(gè)有效的上傳文件
//default: 屬性指定默認(rèn)值
//exist: 驗(yàn)證屬性值在數(shù)據(jù)庫(kù)中是否存在
//boolean: 驗(yàn)證布爾屬性值
//date: 檢驗(yàn)此屬性是否描述了一個(gè)日期、時(shí)間或日期時(shí)間
//safe: 屬性標(biāo)志為在批量賦值時(shí)是安全的。
//unsafe: 標(biāo)志為不安全,所以他們不能被批量賦值。

希望本文所述對(duì)大家基于Yii框架的PHP程序設(shè)計(jì)有所幫助。

更多Yii數(shù)據(jù)模型中rules類驗(yàn)證器用法分析相關(guān)文章請(qǐng)關(guān)注PHP中文網(wǎng)!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276