@fastcar/core 0.2.46 → 0.2.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastcar/core",
3
- "version": "0.2.46",
3
+ "version": "0.2.48",
4
4
  "homepage": "https://github.com/williamDazhangyu/fast-car",
5
5
  "main": "target/index.js",
6
6
  "author": "william_zhong",
@@ -3,7 +3,7 @@ import * as fs from "fs";
3
3
  import * as process from "process";
4
4
  import * as Events from "events";
5
5
  import * as path from "path";
6
- import ClassLoader from "./utils/classLoader";
6
+ import ClassLoader from "./utils/ClassLoader";
7
7
  import FileUtil from "./utils/FileUtil";
8
8
  import MixTool from "./utils/Mix";
9
9
  import TypeUtil from "./utils/TypeUtil";
@@ -53,4 +53,12 @@ export default class TypeUtil {
53
53
  let fname = name.toLowerCase();
54
54
  return BasicTypes.includes(fname);
55
55
  }
56
+
57
+ static isMap(value: any) {
58
+ return value instanceof Map;
59
+ }
60
+
61
+ static isSet(value: any) {
62
+ return value instanceof Set;
63
+ }
56
64
  }
@@ -10,9 +10,10 @@ export default class ValidationUtil {
10
10
  }
11
11
 
12
12
  if (TypeUtil.isObject(param)) {
13
- if (TypeUtil.isDate(param)) {
13
+ if (TypeUtil.isDate(param) || TypeUtil.isMap(param) || TypeUtil.isSet(param)) {
14
14
  return true;
15
15
  }
16
+
16
17
  return Reflect.ownKeys(param).length > 0;
17
18
  }
18
19
 
@@ -15,7 +15,7 @@ const fs = require("fs");
15
15
  const process = require("process");
16
16
  const Events = require("events");
17
17
  const path = require("path");
18
- const classLoader_1 = require("./utils/classLoader");
18
+ const ClassLoader_1 = require("./utils/ClassLoader");
19
19
  const FileUtil_1 = require("./utils/FileUtil");
20
20
  const Mix_1 = require("./utils/Mix");
21
21
  const TypeUtil_1 = require("./utils/TypeUtil");
@@ -99,7 +99,7 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
99
99
  this.delayHotIds.forEach(({ fp, loadType }) => {
100
100
  switch (loadType) {
101
101
  case 1: {
102
- let moduleClass = classLoader_1.default.loadModule(fp, true);
102
+ let moduleClass = ClassLoader_1.default.loadModule(fp, true);
103
103
  this.sysLogger.info("hot update---" + fp);
104
104
  if (moduleClass != null) {
105
105
  moduleClass.forEach((func) => {
@@ -245,7 +245,7 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
245
245
  if (f.startsWith(resp)) {
246
246
  continue;
247
247
  }
248
- let moduleClass = classLoader_1.default.loadModule(f);
248
+ let moduleClass = ClassLoader_1.default.loadModule(f);
249
249
  if (moduleClass != null) {
250
250
  moduleClass.forEach((func, name) => {
251
251
  if (this.componentMap.has(name)) {
@@ -337,7 +337,7 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
337
337
  };
338
338
  if (!fpObj) {
339
339
  fpObj = [fpdesc];
340
- classLoader_1.default.watchServices(fp, this);
340
+ ClassLoader_1.default.watchServices(fp, this);
341
341
  this.watchFiles.set(fp, fpObj);
342
342
  }
343
343
  else {
@@ -549,7 +549,7 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
549
549
  this.loadSysConfig();
550
550
  //监听系统配置
551
551
  if (this.isHotterSysConfig()) {
552
- classLoader_1.default.watchServices(this.getResourcePath(), this, "sysReload");
552
+ ClassLoader_1.default.watchServices(this.getResourcePath(), this, "sysReload");
553
553
  }
554
554
  //开启日志
555
555
  this.startLog();
@@ -43,5 +43,11 @@ class TypeUtil {
43
43
  let fname = name.toLowerCase();
44
44
  return BasicTypes.includes(fname);
45
45
  }
46
+ static isMap(value) {
47
+ return value instanceof Map;
48
+ }
49
+ static isSet(value) {
50
+ return value instanceof Set;
51
+ }
46
52
  }
47
53
  exports.default = TypeUtil;
@@ -10,7 +10,7 @@ class ValidationUtil {
10
10
  return param.length > 0;
11
11
  }
12
12
  if (TypeUtil_1.default.isObject(param)) {
13
- if (TypeUtil_1.default.isDate(param)) {
13
+ if (TypeUtil_1.default.isDate(param) || TypeUtil_1.default.isMap(param) || TypeUtil_1.default.isSet(param)) {
14
14
  return true;
15
15
  }
16
16
  return Reflect.ownKeys(param).length > 0;
@@ -3,6 +3,7 @@ import ValidForm from "../../src/annotation/valid/ValidForm";
3
3
  import NotNull from "../../src/annotation/valid/NotNull";
4
4
  import Size from "../../src/annotation/valid/Size";
5
5
  import { Rule } from "../../src/annotation/valid/Rule";
6
+ import { ValidationUtil } from "../../src/utils";
6
7
 
7
8
  describe("表单校验测试", () => {
8
9
  it("表单单个测试", () => {
@@ -62,4 +63,10 @@ describe("表单校验测试", () => {
62
63
  let instance = new A();
63
64
  instance.test("a", { c: "c", d: 13 }); //校验失败
64
65
  });
66
+
67
+ it("测试map是否为空", () => {
68
+ let d = new Map();
69
+ d.set("hello", "world");
70
+ console.log(ValidationUtil.isNotNull(d) == true);
71
+ });
65
72
  });
package/utils.d.ts CHANGED
@@ -94,6 +94,10 @@ export class TypeUtil {
94
94
 
95
95
  //是否为基本类型
96
96
  static isBasic(name: string): boolean;
97
+
98
+ static isMap(value: any): boolean;
99
+
100
+ static isSet(value: any): boolean;
97
101
  }
98
102
 
99
103
  export class ValidationUtil {
File without changes