mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
改进model类的validate方法
This commit is contained in:
@@ -1893,14 +1893,14 @@ class Model
|
||||
/**
|
||||
* 设置字段验证
|
||||
* @access public
|
||||
* @param mixed $field 字段名或者验证规则 true表示自动读取
|
||||
* @param mixed $field 字段名或者验证规则 true表示自动读取验证器类
|
||||
* @param array|null $rule 验证规则
|
||||
* @return Model
|
||||
*/
|
||||
public function validate($field = true, $rule = null)
|
||||
{
|
||||
if (is_array($field) || is_null($rule)) {
|
||||
$this->options['validate'] = true === $field ? $this->name : $field;
|
||||
if (is_null($rule)) {
|
||||
$this->options['validate'] = $field;
|
||||
} else {
|
||||
$this->options['validate'][$field] = $rule;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user