12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace app\admin\validate\sys_manage;
- use support\Validate;
- class ApiValidate extends Validate
- {
- protected $rule = [
- 'api_id' => 'require|alphaDash',
- 'api_status|状态' => 'require|in:ACTIVED,DISABLED',
- 'api_category|分类' => 'max:32',
- 'api_token|Token' => 'max:32',
- 'api_name|名称' => 'max:64',
- 'api_request_json|请求体配置' => 'isJson',
- 'api_response_json|应答体配置' => 'isJson'
- ];
- protected $scene = [
- 'add' => ['api_status', 'api_category', 'api_token', 'api_name', 'api_request_json', 'api_response_json'],
- 'update' => ['api_id', 'api_status', 'api_category', 'api_token', 'api_name', 'api_request_json', 'api_response_json'],
- ];
- /**
- * @Desc 验证Json
- * @Author Gorden
- * @Date 2024/4/1 13:51
- *
- * @param $value
- * @return string|true
- */
- public function isJson($value)
- {
- if (is_json($value)) {
- return true;
- }
- return "数据格式错误";
- }
- }
|