yii2如何实现自定义验证?
我在模型规则中的代码是
public function rules()
{
return [
[['product_price'], 'checkMaxPrice']
];
}
public function checkMaxPrice($attribute,$params)
{
if($this->product_price > 1000) {
$this->addError($attribute,'Price must be less than 1000');
}
}
我还有什么需要考虑的吗?