From b2f328defc6ccbdeafdbd13a3613a37c2832ec54 Mon Sep 17 00:00:00 2001 From: zhanglei Date: Tue, 18 Apr 2023 14:14:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 考虑到对已使用该组件的项目的兼容,把场景设置的参数放到最后面,不过用起来可能不是很方便,可以自己覆盖实现调整参数位置。 --- src/helper.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/helper.php b/src/helper.php index bbd4160..d8df124 100644 --- a/src/helper.php +++ b/src/helper.php @@ -14,11 +14,12 @@ * @param array $data 数据 * @param string|array $validate 验证器类名或者验证规则数组 * @param array $message 错误提示信息 + * @param string $scene 设置场景 * @param bool $batch 是否批量验证 * @param bool $failException 是否抛出异常 * @return bool */ - function validate(array $data, $validate = '', array $message = [], bool $batch = false, bool $failException = true):bool + function validate(array $data, $validate = '', array $message = [], bool $batch = false, bool $failException = true, string $scene = ''):bool { if (is_array($validate)) { $v = new Validate(); @@ -33,6 +34,6 @@ function validate(array $data, $validate = '', array $message = [], bool $batch } } - return $v->message($message)->batch($batch)->failException($failException)->check($data); + return $v->message($message)->batch($batch)->failException($failException)->scene($scene)->check($data); } -} \ No newline at end of file +}