koatty_validation 1.2.0 → 1.2.2
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/CHANGELOG.md +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -10
- package/dist/index.mjs +4 -10
- package/dist/package.json +1 -1
- package/jest-html-reporters-attach/result.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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.2](https://github.com/koatty/koatty_validation/compare/v1.2.0...v1.2.2) (2022-02-25)
|
|
6
|
+
|
|
5
7
|
## [1.2.0](https://github.com/koatty/koatty_validation/compare/v1.1.0...v1.2.0) (2022-02-25)
|
|
6
8
|
|
|
7
9
|
## [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
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @Author: richen
|
|
3
|
-
* @Date: 2022-02-25
|
|
3
|
+
* @Date: 2022-02-25 10:58:54
|
|
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
|
|
317
|
+
* @LastEditTime: 2022-02-25 10:33:20
|
|
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
|
-
|
|
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
|
}
|
|
@@ -633,10 +630,7 @@ Object.keys(ValidFuncs).forEach((key) => {
|
|
|
633
630
|
options = { message: options, value: null };
|
|
634
631
|
}
|
|
635
632
|
if (!ValidFuncs[key](value, options)) {
|
|
636
|
-
|
|
637
|
-
err.code = 400;
|
|
638
|
-
err.status = 400;
|
|
639
|
-
throw err;
|
|
633
|
+
throw new Error(options.message || `ValidatorError: invalid arguments.`);
|
|
640
634
|
}
|
|
641
635
|
};
|
|
642
636
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* @Author: richen
|
|
3
|
-
* @Date: 2022-02-25
|
|
3
|
+
* @Date: 2022-02-25 10:58:54
|
|
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
|
|
293
|
+
* @LastEditTime: 2022-02-25 10:33:20
|
|
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
|
-
|
|
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
|
}
|
|
@@ -609,10 +606,7 @@ Object.keys(ValidFuncs).forEach((key) => {
|
|
|
609
606
|
options = { message: options, value: null };
|
|
610
607
|
}
|
|
611
608
|
if (!ValidFuncs[key](value, options)) {
|
|
612
|
-
|
|
613
|
-
err.code = 400;
|
|
614
|
-
err.status = 400;
|
|
615
|
-
throw err;
|
|
609
|
+
throw new Error(options.message || `ValidatorError: invalid arguments.`);
|
|
616
610
|
}
|
|
617
611
|
};
|
|
618
612
|
});
|
package/dist/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
window.jest_html_reporters_callback__({"numFailedTestSuites":0,"numFailedTests":0,"numPassedTestSuites":1,"numPassedTests":2,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":1,"numTotalTests":2,"startTime":
|
|
1
|
+
window.jest_html_reporters_callback__({"numFailedTestSuites":0,"numFailedTests":0,"numPassedTestSuites":1,"numPassedTests":2,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":1,"numTotalTests":2,"startTime":1645757930020,"success":false,"testResults":[{"leaks":false,"numFailingTests":0,"numPassingTests":2,"numPendingTests":0,"numTodoTests":0,"perfStats":{"end":1645757932136,"runtime":2047,"slow":false,"start":1645757930089},"skipped":false,"testFilePath":"/Users/richen/Workspace/nodejs/koatty_validation/test/.test.ts","testResults":[{"ancestorTitles":["koatty_validation"],"duration":47,"failureDetails":[],"failureMessages":[],"fullName":"koatty_validation FunctionValidator","invocations":1,"location":null,"numPassingAsserts":0,"status":"passed","title":"FunctionValidator"},{"ancestorTitles":["koatty_validation"],"duration":5,"failureDetails":[],"failureMessages":[],"fullName":"koatty_validation ClassValidator","invocations":1,"location":null,"numPassingAsserts":0,"status":"passed","title":"ClassValidator"}],"failureMessage":null}],"wasInterrupted":false,"config":{"bail":0,"changedFilesWithAncestor":false,"collectCoverage":true,"collectCoverageFrom":[],"coverageDirectory":"coverage","coverageProvider":"babel","coverageReporters":["html","lcov","json","text","clover","text-summary"],"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"expand":false,"findRelatedTests":false,"forceExit":false,"json":false,"lastCommit":false,"listTests":false,"logHeapUsage":false,"maxConcurrency":5,"maxWorkers":7,"noStackTrace":false,"nonFlagArgs":[],"notify":false,"notifyMode":"failure-change","onlyChanged":false,"onlyFailures":false,"passWithNoTests":true,"projects":[],"reporters":[["default",{}],["/Users/richen/Workspace/nodejs/koatty_validation/node_modules/jest-html-reporters/index.js",{}]],"rootDir":"/Users/richen/Workspace/nodejs/koatty_validation","runTestsByPath":false,"skipFilter":false,"testFailureExitCode":1,"testPathPattern":"","testSequencer":"/Users/richen/Workspace/nodejs/koatty_validation/node_modules/@jest/test-sequencer/build/index.js","updateSnapshot":"new","useStderr":false,"verbose":true,"watch":false,"watchAll":false,"watchman":true},"endTime":1645757932333,"_reporterOptions":{"publicPath":"/Users/richen/Workspace/nodejs/koatty_validation","filename":"jest_html_reporters.html","expand":false,"pageTitle":"","hideIcon":false,"testCommand":"npx jest","openReport":false,"failureMessageOnly":false,"enableMergeData":false,"dataMergeLevel":1},"attachInfos":{}})
|
package/package.json
CHANGED