當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Valid::addRule方法代碼示例

本文整理匯總了PHP中Valid::addRule方法的典型用法代碼示例。如果您正苦於以下問題:PHP Valid::addRule方法的具體用法?PHP Valid::addRule怎麽用?PHP Valid::addRule使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Valid的用法示例。


在下文中一共展示了Valid::addRule方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: process

 function process()
 {
     session_require(array('group' => '1', 'admin_flags' => 'A'));
     $request =& HTTPRequest::instance();
     $valid = new Valid('offset');
     $valid->setErrorMessage('Invalid offset submitted. Force it to 0 (zero).');
     $valid->addRule(new Rule_Int());
     $valid->addRule(new Rule_GreaterOrEqual(0));
     if ($request->valid($valid)) {
         $offset = $request->get('offset');
     } else {
         $offset = 0;
     }
     $valid = new Valid('day');
     $valid->addRule(new Rule_Date(), 'Invalid date submitted. Force it to today.');
     if ($request->valid($valid)) {
         $day = $request->get('day');
     } else {
         $day = date('Y-n-j');
     }
     $userLogManager = new UserLogManager();
     $userLogManager->displayLogs($offset, $day);
 }
開發者ID:pombredanne,項目名稱:tuleap,代碼行數:23,代碼來源:userlogPlugin.class.php

示例2: Valid

} else {
    $func = 'show_service';
}
$vStartDate = new Valid('start_date');
$vStartDate->addRule(new Rule_Date());
$vStartDate->required();
if ($request->valid($vStartDate)) {
    $startDate = $request->get('start_date');
} else {
    $startDate = date('Y-m-d', strtotime('-1 week'));
}
if (strtotime($startDate) < strtotime('-3 months')) {
    $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_statistics', 'querying_purged_data'));
}
$vEndDate = new Valid('end_date');
$vEndDate->addRule(new Rule_Date());
$vEndDate->required();
if ($request->valid($vStartDate)) {
    $endDate = $request->get('end_date');
} else {
    $endDate = date('Y-m-d');
}
if (strtotime($startDate) >= strtotime($endDate)) {
    $GLOBALS['Response']->addFeedback('error', 'You made a mistake in selecting period. Please try again!');
}
$vGroupId = new Valid_UInt('group_id');
$vGroupId->required();
if ($request->valid($vGroupId)) {
    $groupId = $request->get('group_id');
} else {
    $groupId = '';
開發者ID:pombredanne,項目名稱:tuleap,代碼行數:31,代碼來源:disk_usage.php

示例3: testRequiredAndPermissive

 /**
  * Need to throw an error if the value is required but the rule return true
  * even with empty values
  */
 function testRequiredAndPermissive()
 {
     $r =& new MockRule($this);
     $r->setReturnValue('isValid', true);
     $v = new Valid();
     $v->disableFeedback();
     $v->required();
     $v->addRule($r);
     $this->assertFalse($v->validate(''));
 }
開發者ID:pombredanne,項目名稱:tuleap,代碼行數:14,代碼來源:ValidTest.php

示例4: array

}
// Validate action
$vAction = new Valid_Whitelist('action', array('update_user'));
$vAction->required();
if ($request->valid($vAction)) {
    $action = $request->get('action');
} else {
    $action = '';
}
if ($request->isPost()) {
    if ($action == 'update_user') {
        /*
         * Update the user
         */
        $vDate = new Valid('expiry_date');
        $vDate->addRule(new Rule_Date());
        //$vDate->required();
        if (!$request->valid($vDate)) {
            $GLOBALS['Response']->addFeedback('error', $Language->getText('admin_usergroup', 'data_not_parsed'));
        } else {
            if ($request->existAndNonEmpty('expiry_date')) {
                $date_list = split('-', $request->get('expiry_date'), 3);
                $unix_expiry_time = mktime(0, 0, 0, $date_list[1], $date_list[2], $date_list[0]);
                if ($user->getExpiryDate() != $unix_expiry_time) {
                    $user->setExpiryDate($unix_expiry_time);
                }
            } else {
                if ($user->getExpiryDate()) {
                    $user->setExpiryDate('');
                }
            }
開發者ID:nterray,項目名稱:tuleap,代碼行數:31,代碼來源:usergroup.php


注:本文中的Valid::addRule方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。