Skip to content

Commit

Permalink
feat(Validator): 校验的键名可以传入数组,表示校验相应数据路径的数据
Browse files Browse the repository at this point in the history
  • Loading branch information
twinh committed Nov 24, 2020
1 parent b46b327 commit bac0a23
Show file tree
Hide file tree
Showing 4 changed files with 262 additions and 102 deletions.
9 changes: 8 additions & 1 deletion lib/V.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class V extends Base
'data' => [],
'rules' => [],
'names' => [],
'fields' => [],
];

/**
Expand Down Expand Up @@ -245,13 +246,19 @@ protected function label($label)
/**
* Add a new field
*
* @param string $name
* @param string|array $name
* @param string|null $label
* @return $this
* @svc
*/
protected function key($name, $label = null)
{
if (is_array($name)) {
$key = implode('.', $name);
$this->options['fields'][$key] = $name;
$name = $key;
}

$this->lastKey = $name;

// Rest previous key's last rule
Expand Down
Loading

0 comments on commit bac0a23

Please sign in to comment.