@fastcar/core 0.2.61 → 0.2.62

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.61",
3
+ "version": "0.2.62",
4
4
  "homepage": "https://github.com/williamDazhangyu/fast-car",
5
5
  "main": "target/index.js",
6
6
  "author": "william_zhong",
@@ -1,8 +1,6 @@
1
1
  import { DataTypes } from "../constant/DataTypes";
2
2
  import TypeUtil from "./TypeUtil";
3
3
 
4
- const NumberRegex = /^[0-9]+$/;
5
-
6
4
  //类型校验器
7
5
  export default class ValidationUtil {
8
6
  //是否为空
@@ -32,7 +30,7 @@ export default class ValidationUtil {
32
30
 
33
31
  //修改数字的判断方法
34
32
  static isNumber(param: any): boolean {
35
- return NumberRegex.test(param);
33
+ return !isNaN(param);
36
34
  }
37
35
 
38
36
  static isString(param: any): boolean {
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const TypeUtil_1 = require("./TypeUtil");
4
- const NumberRegex = /^[0-9]+$/;
5
4
  //类型校验器
6
5
  class ValidationUtil {
7
6
  //是否为空
@@ -27,7 +26,7 @@ class ValidationUtil {
27
26
  }
28
27
  //修改数字的判断方法
29
28
  static isNumber(param) {
30
- return NumberRegex.test(param);
29
+ return !isNaN(param);
31
30
  }
32
31
  static isString(param) {
33
32
  return typeof param === "string";
@@ -7,66 +7,71 @@ import { ValidationUtil } from "../../src/utils";
7
7
 
8
8
  describe("表单校验测试", () => {
9
9
  it("表单单个测试", () => {
10
- class A {
11
- //简单类型
12
- @ValidForm
13
- test(@Rule() @NotNull a?: string) {
14
- console.log(a);
15
- }
16
- }
17
- let instance = new A();
18
- instance.test("");
19
- });
20
-
21
- it("表单复合型测试", () => {
22
- type B = {
23
- c: string;
24
- d?: number;
25
- };
26
10
  class A {
27
11
  //简单类型
28
12
  @ValidForm
29
13
  test(
30
14
  @Rule({
31
- a: { required: true },
32
- })
33
- a: string,
34
- @Rule({
35
- c: { required: true },
36
- d: { type: "number", minSize: 1, maxSize: 10 },
15
+ a: { required: true, type: "int" },
37
16
  })
38
- b: B
17
+ { a }: { a: any }
39
18
  ) {
40
- console.log(a, b);
19
+ console.log(a);
41
20
  }
42
21
  }
43
- let instance = new A();
44
- instance.test("a", { c: "c", d: 6 }); // 校验通过
45
- instance.test("a", { c: "c", d: 13 }); //校验失败
22
+ console.log("");
23
+ new A().test({ a: [] });
46
24
  });
47
25
 
48
- it("表单类测试", () => {
49
- class B {
50
- @NotNull
51
- c!: string;
26
+ // it("表单复合型测试", () => {
27
+ // type B = {
28
+ // c: string;
29
+ // d?: number;
30
+ // };
31
+ // class A {
32
+ // //简单类型
33
+ // @ValidForm
34
+ // test(
35
+ // @Rule({
36
+ // a: { required: true },
37
+ // })
38
+ // a: string,
39
+ // @Rule({
40
+ // c: { required: true },
41
+ // d: { type: "number", minSize: 1, maxSize: 10 },
42
+ // })
43
+ // b: B
44
+ // ) {
45
+ // console.log(a, b);
46
+ // }
47
+ // }
48
+ // let instance = new A();
49
+ // instance.test("a", { c: "c", d: 6 }); // 校验通过
50
+ // instance.test("a", { c: "c", d: 13 }); //校验失败
51
+ // });
52
52
 
53
- @Size({ minSize: 1, maxSize: 10 })
54
- d?: number;
55
- }
56
- class A {
57
- //简单类型
58
- @ValidForm
59
- test(a: string, @Rule() @NotNull b: B) {
60
- console.log(a, b);
61
- }
62
- }
63
- let instance = new A();
64
- instance.test("a", { c: "c", d: 13 }); //校验失败
65
- });
53
+ // it("表单类测试", () => {
54
+ // class B {
55
+ // @NotNull
56
+ // c!: string;
66
57
 
67
- it("测试map是否为空", () => {
68
- let d = new Map();
69
- d.set("hello", "world");
70
- console.log(ValidationUtil.isNotNull(d) == true);
71
- });
58
+ // @Size({ minSize: 1, maxSize: 10 })
59
+ // d?: number;
60
+ // }
61
+ // class A {
62
+ // //简单类型
63
+ // @ValidForm
64
+ // test(a: string, @Rule() @NotNull b: B) {
65
+ // console.log(a, b);
66
+ // }
67
+ // }
68
+ // let instance = new A();
69
+ // instance.test("a", { c: "c", d: 13 }); //校验失败
70
+ // });
71
+
72
+ // it("测试map是否为空", () => {
73
+ // let d = new Map();
74
+ // d.set("hello", "world");
75
+ // console.log(ValidationUtil.isNotNull(d) == true);
76
+ // });
72
77
  });