本文整理汇总了PHP中BaseElementModel::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseElementModel::validate方法的具体用法?PHP BaseElementModel::validate怎么用?PHP BaseElementModel::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseElementModel
的用法示例。
在下文中一共展示了BaseElementModel::validate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
public function validate($attributes = null, $clear = TRUE)
{
parent::validate($attributes, false);
if ($this->planCoupon != '') {
$model = craft()->charge_coupon->handleCoupon($this);
}
return !$this->hasErrors();
}
示例2: validate
/**
* Validates all of the attributes for the current Model. Any attributes that fail validation will additionally get
* logged to the `craft/storage/runtime/logs` folder with a level of LogLevel::Warning.
*
* In addition, we check that the username does not have any whitespace in it.
*
* @param null $attributes
* @param bool $clearErrors
*
* @return bool|null
*/
public function validate($attributes = null, $clearErrors = true)
{
// Don't allow whitespace in the username.
if (preg_match('/\\s+/', $this->username)) {
$this->addError('username', Craft::t('Spaces are not allowed in the username.'));
}
return parent::validate($attributes, false);
}