This commit is contained in:
2026-08-18 17:17:08 +08:00
parent 38a6f81b39
commit d6a9b93f29

View File

@@ -14,6 +14,7 @@ use Hyperf\Di\Annotation\Inject;
use Hyperf\Validation\Contract\ValidatorFactoryInterface;
use Hyperf\Validation\Validator as HyperfValidator;
use RuntimeException;
use Hyperf\Collection\Arr;
abstract class Validator
{
@@ -128,6 +129,17 @@ abstract class Validator
}
}
/**
* 获取待验证数据中指定键的值.
* 如果不存在该键,则返回null.
* @param string $key 待获取的键名
* @return mixed 键对应的值
*/
protected function getDataByKey(string $key): mixed
{
return Arr::get($this->data, $key);
}
/**
* 定义场景验证规则(子类实现).
*/