| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 | 
							- <?php
 
- namespace app\admin\validate\device;
 
- use think\Validate;
 
- class DeviceValidate extends Validate
 
- {
 
-     /**
 
-      * 规则
 
-      * @var string[]
 
-      */
 
-     protected $rule = [
 
-         'device_id' => 'require|alphaDash',
 
-         'join_device_ledger_id' => 'require|integer',
 
-         'device_status|设备状态' => 'require|in:WAITING,PROCESSING,PENDING,ACTIVED,DISABLED',
 
-         'device_category|分类' => 'max:32',
 
-         'device_type类型' => 'max:32',
 
-         'device_identify|标识' => 'max:32',
 
-         'device_name|名称' => 'max:32',
 
-         'device_config_json' => 'isJson',
 
-         'device_extend_json' => 'isJson',
 
-     ];
 
-     /**
 
-      * 场景
 
-      * @var array[]
 
-      */
 
-     protected $scene = [
 
-         'add' => ['join_device_ledger_id', 'device_status', 'device_category', 'device_type', 'device_identify', 'device_name', 'device_config_json', 'device_extend_json'],
 
-         'update' => ['device_id','join_device_ledger_id', 'device_status', 'device_category', 'device_type', 'device_identify', 'device_name', 'device_config_json', 'device_extend_json'],
 
-     ];
 
-     /**
 
-      * @Desc 验证Json
 
-      * @Author Gorden
 
-      * @Date 2024/3/26 13:36
 
-      *
 
-      * @param $value
 
-      * @return string|true
 
-      */
 
-     public function isJson($value){
 
-         if (is_json($value)){
 
-             return true;
 
-         }
 
-         return '数据格式错误';
 
-     }
 
- }
 
 
  |