本文整理汇总了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);
}
示例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 = '';
示例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(''));
}
示例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('');
}
}