We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
验证器的核心check方法中,会有对场景的判断
// 获取场景定义() $this->getScene($scene);
// protected function getScene($scene = '') { if (empty($scene)) { // 读取指定场景 $scene = $this->currentScene; }
是否有考虑过check 之后,属性currentScene 回归成 null,要不然如果连续两次调用验证器,上次的scene 会带入下一次,感觉并不是太好,比如先验证是否有id (edit 情况), 如果id 不存在,则验证 默认的情况。
像这样,我只是调用validate 方法,但是scene : edit 会携带着进入下次 validate 方法调用 $result = $this->validate( [ 'name' => 'thinkphp', 'email' => '[email protected]', ], 'app\index\validator\User.edit');
The text was updated successfully, but these errors were encountered:
看了validate make 静态调用能解决上述问题,通过每次new self,上面提到的只是使用check时候的一些看法意见
Sorry, something went wrong.
No branches or pull requests
验证器的核心check方法中,会有对场景的判断
// 获取场景定义()
$this->getScene($scene);
//
protected function getScene($scene = '')
{
if (empty($scene)) {
// 读取指定场景
$scene = $this->currentScene;
}
是否有考虑过check 之后,属性currentScene 回归成 null,要不然如果连续两次调用验证器,上次的scene 会带入下一次,感觉并不是太好,比如先验证是否有id (edit 情况), 如果id 不存在,则验证 默认的情况。
像这样,我只是调用validate 方法,但是scene : edit 会携带着进入下次 validate 方法调用
$result = $this->validate(
[
'name' => 'thinkphp',
'email' => '[email protected]',
],
'app\index\validator\User.edit');
The text was updated successfully, but these errors were encountered: