验证器¶
属性 | 值 |
---|---|
命名空间 | fize\security |
类名 | Validator |
方法: |
---|
方法名 | 说明 |
---|---|
__construct() | 构造 |
rules() | 规则定义 |
names() | 命名定义 |
validate() | 添加验证器信息定义 |
messages() | 信息定义 |
scenes() | 场景定义 |
hasScene() | 是否有指定场景 |
scene() | 场景指定 |
batch() | 设置是否批量验证 |
sceneRules() | 设置场景规则重定义 |
sceneNames() | 设置场景字段命名重定义 |
sceneMessages() | 设置场景信息重定义 |
check() | 验证数据 |
方法¶
validate()¶
添加验证器信息定义
public function validate (
string $validate,
string $description
)
参数: |
|
---|
sceneRules()¶
设置场景规则重定义
public function sceneRules (
string $scene,
array $rules
)
参数: |
|
---|
sceneNames()¶
设置场景字段命名重定义
public function sceneNames (
string $scene,
array $names
)
参数: |
|
---|
sceneMessages()¶
设置场景信息重定义
public function sceneMessages (
string $scene,
array $messages
)
参数: |
|
---|
check()¶
验证数据
public function check (
array $data
) : bool|string|array
参数: |
|
||||
---|---|---|---|---|---|
返回值: | 成功返回 true,失败返回失败信息 |
如果启用批量验证,则失败时返回值为错误数组,否则为错误信息