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