mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-03 22:02:48 +08:00
controller和model类的validate方法支持指定场景 例如 $this->validate('User.edit');
This commit is contained in:
@@ -993,8 +993,14 @@ class Model
|
||||
$validate->rule($info['rule']);
|
||||
$validate->message($info['msg']);
|
||||
} else {
|
||||
$name = is_string($info) ? $info : $this->name;
|
||||
$name = is_string($info) ? $info : $this->name;
|
||||
if (strpos($name, '.')) {
|
||||
list($name, $scene) = explode('.', $name);
|
||||
}
|
||||
$validate = Loader::validate($name);
|
||||
if (!empty($scene)) {
|
||||
$validate->scene($scene);
|
||||
}
|
||||
}
|
||||
if (!$validate->check($data)) {
|
||||
$this->error = $validate->getError();
|
||||
|
||||
Reference in New Issue
Block a user