本文整理匯總了PHP中Valid::required方法的典型用法代碼示例。如果您正苦於以下問題:PHP Valid::required方法的具體用法?PHP Valid::required怎麽用?PHP Valid::required使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Valid
的用法示例。
在下文中一共展示了Valid::required方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Valid
$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 = '';
}
示例2: 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(''));
}