koatty_validation 1.2.0 → 1.2.4

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.
@@ -0,0 +1,63 @@
1
+ /*
2
+ * @Description:
3
+ * @Usage:
4
+ * @Author: richen
5
+ * @Date: 2021-12-17 10:20:44
6
+ * @LastEditTime: 2021-12-18 11:58:46
7
+ */
8
+ import json from "@rollup/plugin-json";
9
+ import typescript from 'rollup-plugin-typescript2';
10
+ // import babel from '@rollup/plugin-babel';
11
+
12
+ export default [
13
+ {
14
+ input: './src/index.ts',
15
+ output: [{
16
+ format: 'cjs',
17
+ file: './dist/index.js',
18
+ banner: require('./scripts/copyright')
19
+ }],
20
+ plugins: [
21
+ // babel({
22
+ // babelHelpers: "runtime",
23
+ // configFile: './babel.config.js',
24
+ // exclude: 'node_modules/**',
25
+ // }),
26
+ json(),
27
+ typescript({
28
+ tsconfigOverride: {
29
+ compilerOptions: {
30
+ declaration: false,
31
+ declarationMap: false,
32
+ module: "ESNext"
33
+ }
34
+ }
35
+ })
36
+ ]
37
+ },
38
+ {
39
+ input: './src/index.ts',
40
+ output: [{
41
+ format: 'es',
42
+ file: './dist/index.mjs',
43
+ banner: require('./scripts/copyright')
44
+ }],
45
+ plugins: [
46
+ // babel({
47
+ // babelHelpers: "runtime",
48
+ // configFile: './babel.config.js',
49
+ // exclude: 'node_modules/**',
50
+ // }),
51
+ json(),
52
+ typescript({
53
+ tsconfigOverride: {
54
+ compilerOptions: {
55
+ declaration: false,
56
+ declarationMap: false,
57
+ module: "ESNext"
58
+ }
59
+ }
60
+ })
61
+ ]
62
+ }
63
+ ]
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.2.4](https://github.com/koatty/koatty_validation/compare/v1.2.3...v1.2.4) (2022-05-27)
6
+
7
+ ### [1.2.3](https://github.com/koatty/koatty_validation/compare/v1.2.2...v1.2.3) (2022-03-09)
8
+
9
+ ### [1.2.2](https://github.com/koatty/koatty_validation/compare/v1.2.0...v1.2.2) (2022-02-25)
10
+
5
11
  ## [1.2.0](https://github.com/koatty/koatty_validation/compare/v1.1.0...v1.2.0) (2022-02-25)
6
12
 
7
13
  ## [1.1.0](https://github.com/koatty/koatty_validation/compare/v1.0.12...v1.1.0) (2022-02-16)
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2022-02-25 09:58:15
3
+ * @Date: 2022-05-27 09:55:28
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2022-02-25 09:58:02
3
+ * @Date: 2022-05-27 09:55:14
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -314,7 +314,7 @@ function plateNumber(value) {
314
314
  * @Usage:
315
315
  * @Author: richen
316
316
  * @Date: 2021-11-25 10:47:04
317
- * @LastEditTime: 2022-02-25 09:51:04
317
+ * @LastEditTime: 2022-03-09 18:23:18
318
318
  */
319
319
  // constant
320
320
  const PARAM_TYPE_KEY = 'PARAM_TYPE_KEY';
@@ -388,10 +388,7 @@ class ValidateClass {
388
388
  errors = await classValidator.validate(obj, { skipMissingProperties: true });
389
389
  }
390
390
  if (errors.length > 0) {
391
- const err = new Error(Object.values(errors[0].constraints)[0]);
392
- err.code = 400;
393
- err.status = 400;
394
- throw err;
391
+ throw new Error(Object.values(errors[0].constraints)[0]);
395
392
  }
396
393
  return obj;
397
394
  }
@@ -632,11 +629,8 @@ Object.keys(ValidFuncs).forEach((key) => {
632
629
  if (helper__namespace.isString(options)) {
633
630
  options = { message: options, value: null };
634
631
  }
635
- if (!ValidFuncs[key](value, options)) {
636
- const err = new Error(options.message || `ValidatorError: invalid arguments.`);
637
- err.code = 400;
638
- err.status = 400;
639
- throw err;
632
+ if (!ValidFuncs[key](value, options.value)) {
633
+ throw new Error(options.message || `ValidatorError: invalid arguments.`);
640
634
  }
641
635
  };
642
636
  });
@@ -646,7 +640,7 @@ Object.keys(ValidFuncs).forEach((key) => {
646
640
  * @Usage:
647
641
  * @Author: richen
648
642
  * @Date: 2021-11-25 10:46:57
649
- * @LastEditTime: 2022-02-24 15:33:34
643
+ * @LastEditTime: 2022-03-02 11:23:27
650
644
  */
651
645
  /**
652
646
  * Validation parameter's type and values.
@@ -666,9 +660,10 @@ function Valid(rule, options) {
666
660
  rules = rule;
667
661
  }
668
662
  return (target, propertyKey, descriptor) => {
663
+ var _a;
669
664
  // 获取成员参数类型
670
665
  const paramTypes = Reflect.getMetadata("design:paramtypes", target, propertyKey);
671
- const type = (paramTypes[descriptor] && paramTypes[descriptor].name) ? paramTypes[descriptor].name : "object";
666
+ const type = ((_a = paramTypes[descriptor]) === null || _a === void 0 ? void 0 : _a.name) ? paramTypes[descriptor].name : 'object';
672
667
  if (helper__namespace.isString(options)) {
673
668
  options = { message: options, value: null };
674
669
  }
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2022-02-25 09:58:02
3
+ * @Date: 2022-05-27 09:55:14
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -290,7 +290,7 @@ function plateNumber(value) {
290
290
  * @Usage:
291
291
  * @Author: richen
292
292
  * @Date: 2021-11-25 10:47:04
293
- * @LastEditTime: 2022-02-25 09:51:04
293
+ * @LastEditTime: 2022-03-09 18:23:18
294
294
  */
295
295
  // constant
296
296
  const PARAM_TYPE_KEY = 'PARAM_TYPE_KEY';
@@ -364,10 +364,7 @@ class ValidateClass {
364
364
  errors = await validate(obj, { skipMissingProperties: true });
365
365
  }
366
366
  if (errors.length > 0) {
367
- const err = new Error(Object.values(errors[0].constraints)[0]);
368
- err.code = 400;
369
- err.status = 400;
370
- throw err;
367
+ throw new Error(Object.values(errors[0].constraints)[0]);
371
368
  }
372
369
  return obj;
373
370
  }
@@ -608,11 +605,8 @@ Object.keys(ValidFuncs).forEach((key) => {
608
605
  if (helper.isString(options)) {
609
606
  options = { message: options, value: null };
610
607
  }
611
- if (!ValidFuncs[key](value, options)) {
612
- const err = new Error(options.message || `ValidatorError: invalid arguments.`);
613
- err.code = 400;
614
- err.status = 400;
615
- throw err;
608
+ if (!ValidFuncs[key](value, options.value)) {
609
+ throw new Error(options.message || `ValidatorError: invalid arguments.`);
616
610
  }
617
611
  };
618
612
  });
@@ -622,7 +616,7 @@ Object.keys(ValidFuncs).forEach((key) => {
622
616
  * @Usage:
623
617
  * @Author: richen
624
618
  * @Date: 2021-11-25 10:46:57
625
- * @LastEditTime: 2022-02-24 15:33:34
619
+ * @LastEditTime: 2022-03-02 11:23:27
626
620
  */
627
621
  /**
628
622
  * Validation parameter's type and values.
@@ -642,9 +636,10 @@ function Valid(rule, options) {
642
636
  rules = rule;
643
637
  }
644
638
  return (target, propertyKey, descriptor) => {
639
+ var _a;
645
640
  // 获取成员参数类型
646
641
  const paramTypes = Reflect.getMetadata("design:paramtypes", target, propertyKey);
647
- const type = (paramTypes[descriptor] && paramTypes[descriptor].name) ? paramTypes[descriptor].name : "object";
642
+ const type = ((_a = paramTypes[descriptor]) === null || _a === void 0 ? void 0 : _a.name) ? paramTypes[descriptor].name : 'object';
648
643
  if (helper.isString(options)) {
649
644
  options = { message: options, value: null };
650
645
  }
package/dist/package.json CHANGED
@@ -1,24 +1,18 @@
1
1
  {
2
2
  "name": "koatty_validation",
3
- "version": "1.2.0",
3
+ "version": "1.2.4",
4
4
  "description": "Validation Util for Koatty and ThinkORM.",
5
5
  "scripts": {
6
6
  "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
7
7
  "build:cp": "node scripts/postBuild && copyfiles package.json LICENSE README.md dist/",
8
- "build:js": "del-cli --force dist && npx rollup -c",
8
+ "build:js": "del-cli --force dist && npx rollup -c .rollup.config.js",
9
9
  "build:doc": "del-cli --force docs/api && npx api-documenter markdown --input temp --output docs/api",
10
10
  "build:dts": "del-cli --force temp && npx tsc && npx api-extractor run --local --verbose",
11
11
  "eslint": "eslint --ext .ts,.js ./",
12
12
  "prepublishOnly": "npm test && npm run build",
13
13
  "prerelease": "npm test && npm run build",
14
14
  "release": "standard-version",
15
- "release:pre": "npm run release -- --prerelease",
16
- "release:major": "npm run release -- --release-as major",
17
- "release:minor": "npm run release -- --release-as minor",
18
- "pub": "git push --follow-tags origin && npm publish",
19
- "test": "npm run eslint && jest --passWithNoTests",
20
- "test:cov": "jest --collectCoverage --detectOpenHandles",
21
- "version": "conventional-changelog -p angular -i CHANGELOG.md -s"
15
+ "test": "npm run eslint && jest --passWithNoTests"
22
16
  },
23
17
  "main": "./dist/index.js",
24
18
  "exports": {
@@ -48,29 +42,29 @@
48
42
  }
49
43
  ],
50
44
  "devDependencies": {
45
+ "@commitlint/cli": "^17.x.x",
46
+ "@commitlint/config-conventional": "^17.x.x",
51
47
  "@microsoft/api-documenter": "^7.x.x",
52
48
  "@microsoft/api-extractor": "^7.x.x",
53
49
  "@rollup/plugin-json": "^4.x.x",
54
50
  "@types/jest": "^27.x.x",
55
51
  "@types/koa": "^2.x.x",
56
52
  "@types/node": "^16.x.x",
57
- "@types/validator": "^13.x.x",
53
+ "@types/validator": "^13.7.2",
58
54
  "@typescript-eslint/eslint-plugin": "^5.x.x",
59
55
  "@typescript-eslint/parser": "^5.x.x",
60
- "commitlint": "^15.x.x",
61
- "commitlint-config-gitmoji": "^2.x.x",
62
56
  "conventional-changelog-cli": "^2.x.x",
63
57
  "copyfiles": "^2.x.x",
64
58
  "del-cli": "^4.x.x",
65
59
  "eslint": "^8.x.x",
66
- "eslint-plugin-jest": "^25.x.x",
67
- "husky": "^7.x.x",
68
- "jest": "^27.x.x",
69
- "jest-html-reporters": "^2.x.x",
60
+ "eslint-plugin-jest": "^26.x.x",
61
+ "husky": "^4.x.x",
62
+ "jest": "^28.x.x",
63
+ "jest-html-reporters": "^3.x.x",
70
64
  "rollup": "^2.x.x",
71
65
  "rollup-plugin-typescript2": "^0.x.x",
72
66
  "standard-version": "^9.x.x",
73
- "ts-jest": "^27.x.x",
67
+ "ts-jest": "^28.x.x",
74
68
  "ts-node": "^10.x.x",
75
69
  "typescript": "^4.x.x"
76
70
  },
@@ -80,11 +74,11 @@
80
74
  "koatty_lib": "^1.x.x",
81
75
  "koatty_logger": "^1.x.x",
82
76
  "reflect-metadata": "^0.1.13",
83
- "tslib": "^2.3.1"
77
+ "tslib": "^2.4.0"
84
78
  },
85
79
  "peerDependencies": {
86
80
  "koatty_container": "^1.x.x",
87
81
  "koatty_lib": "^1.x.x",
88
82
  "koatty_logger": "^1.x.x"
89
83
  }
90
- }
84
+ }
package/package.json CHANGED
@@ -1,24 +1,18 @@
1
1
  {
2
2
  "name": "koatty_validation",
3
- "version": "1.2.0",
3
+ "version": "1.2.4",
4
4
  "description": "Validation Util for Koatty and ThinkORM.",
5
5
  "scripts": {
6
6
  "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
7
7
  "build:cp": "node scripts/postBuild && copyfiles package.json LICENSE README.md dist/",
8
- "build:js": "del-cli --force dist && npx rollup -c",
8
+ "build:js": "del-cli --force dist && npx rollup -c .rollup.config.js",
9
9
  "build:doc": "del-cli --force docs/api && npx api-documenter markdown --input temp --output docs/api",
10
10
  "build:dts": "del-cli --force temp && npx tsc && npx api-extractor run --local --verbose",
11
11
  "eslint": "eslint --ext .ts,.js ./",
12
12
  "prepublishOnly": "npm test && npm run build",
13
13
  "prerelease": "npm test && npm run build",
14
14
  "release": "standard-version",
15
- "release:pre": "npm run release -- --prerelease",
16
- "release:major": "npm run release -- --release-as major",
17
- "release:minor": "npm run release -- --release-as minor",
18
- "pub": "git push --follow-tags origin && npm publish",
19
- "test": "npm run eslint && jest --passWithNoTests",
20
- "test:cov": "jest --collectCoverage --detectOpenHandles",
21
- "version": "conventional-changelog -p angular -i CHANGELOG.md -s"
15
+ "test": "npm run eslint && jest --passWithNoTests"
22
16
  },
23
17
  "main": "./dist/index.js",
24
18
  "exports": {
@@ -48,29 +42,29 @@
48
42
  }
49
43
  ],
50
44
  "devDependencies": {
45
+ "@commitlint/cli": "^17.x.x",
46
+ "@commitlint/config-conventional": "^17.x.x",
51
47
  "@microsoft/api-documenter": "^7.x.x",
52
48
  "@microsoft/api-extractor": "^7.x.x",
53
49
  "@rollup/plugin-json": "^4.x.x",
54
50
  "@types/jest": "^27.x.x",
55
51
  "@types/koa": "^2.x.x",
56
52
  "@types/node": "^16.x.x",
57
- "@types/validator": "^13.x.x",
53
+ "@types/validator": "^13.7.2",
58
54
  "@typescript-eslint/eslint-plugin": "^5.x.x",
59
55
  "@typescript-eslint/parser": "^5.x.x",
60
- "commitlint": "^15.x.x",
61
- "commitlint-config-gitmoji": "^2.x.x",
62
56
  "conventional-changelog-cli": "^2.x.x",
63
57
  "copyfiles": "^2.x.x",
64
58
  "del-cli": "^4.x.x",
65
59
  "eslint": "^8.x.x",
66
- "eslint-plugin-jest": "^25.x.x",
67
- "husky": "^7.x.x",
68
- "jest": "^27.x.x",
69
- "jest-html-reporters": "^2.x.x",
60
+ "eslint-plugin-jest": "^26.x.x",
61
+ "husky": "^4.x.x",
62
+ "jest": "^28.x.x",
63
+ "jest-html-reporters": "^3.x.x",
70
64
  "rollup": "^2.x.x",
71
65
  "rollup-plugin-typescript2": "^0.x.x",
72
66
  "standard-version": "^9.x.x",
73
- "ts-jest": "^27.x.x",
67
+ "ts-jest": "^28.x.x",
74
68
  "ts-node": "^10.x.x",
75
69
  "typescript": "^4.x.x"
76
70
  },
@@ -80,11 +74,11 @@
80
74
  "koatty_lib": "^1.x.x",
81
75
  "koatty_logger": "^1.x.x",
82
76
  "reflect-metadata": "^0.1.13",
83
- "tslib": "^2.3.1"
77
+ "tslib": "^2.4.0"
84
78
  },
85
79
  "peerDependencies": {
86
80
  "koatty_container": "^1.x.x",
87
81
  "koatty_lib": "^1.x.x",
88
82
  "koatty_logger": "^1.x.x"
89
83
  }
90
- }
84
+ }