其余文件
This commit is contained in:
32
app/api/validate/UpdateUserValidate.php
Normal file
32
app/api/validate/UpdateUserValidate.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace app\api\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class UpdateUserValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'field' => 'require|checkField',
|
||||
'value' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'field.require' => '请填写要修改的字段',
|
||||
'value.require' => '请填写要修改的值',
|
||||
];
|
||||
|
||||
|
||||
public function sceneSet()
|
||||
{
|
||||
$this->only(['field', 'value']);
|
||||
}
|
||||
|
||||
protected function checkField($value, $rule, $data)
|
||||
{
|
||||
$allow_field = ['nickname', 'sex', 'avatar'];
|
||||
if (in_array($value, $allow_field)) {
|
||||
return true;
|
||||
}
|
||||
return '非法字段';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user