@atscript/moost-validator 0.0.29 → 0.0.31
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/dist/index.cjs +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -22,13 +22,13 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
|
|
24
24
|
//#endregion
|
|
25
|
-
const
|
|
25
|
+
const __atscript_typescript_utils = __toESM(require("@atscript/typescript/utils"));
|
|
26
26
|
const moost = __toESM(require("moost"));
|
|
27
27
|
const __moostjs_event_http = __toESM(require("@moostjs/event-http"));
|
|
28
28
|
|
|
29
29
|
//#region packages/moost-validator/src/as-validator.pipe.ts
|
|
30
30
|
const validatorPipe = (opts) => (0, moost.definePipeFn)((value, metas, level) => {
|
|
31
|
-
if ((0,
|
|
31
|
+
if ((0, __atscript_typescript_utils.isAnnotatedType)(metas?.targetMeta?.type) && typeof metas.targetMeta.type.validator === "function") {
|
|
32
32
|
const validator = metas.targetMeta.type.validator(opts);
|
|
33
33
|
validator.validate(value);
|
|
34
34
|
}
|
|
@@ -46,7 +46,7 @@ const validationErrorTransform = () => (0, moost.defineInterceptorFn)((before, a
|
|
|
46
46
|
* Internal helper that performs the actual conversion: wraps a
|
|
47
47
|
* `ValidatorError` into {@link HttpError} and passes it to Moost's `reply`.
|
|
48
48
|
*/ function transformValidationError(error, reply) {
|
|
49
|
-
if (error instanceof
|
|
49
|
+
if (error instanceof __atscript_typescript_utils.ValidatorError) reply(new __moostjs_event_http.HttpError(400, {
|
|
50
50
|
message: error.message,
|
|
51
51
|
statusCode: 400,
|
|
52
52
|
_body: error.errors
|
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ValidatorError, isAnnotatedType } from "@atscript/typescript";
|
|
1
|
+
import { ValidatorError, isAnnotatedType } from "@atscript/typescript/utils";
|
|
2
2
|
import { Intercept, Pipe, TInterceptorPriority, TPipePriority, defineInterceptorFn, definePipeFn } from "moost";
|
|
3
3
|
import { HttpError } from "@moostjs/event-http";
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/moost-validator",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"description": "Validator pipe and utils for Moost.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@moostjs/event-http": "^0.5.32",
|
|
43
43
|
"moost": "^0.5.32",
|
|
44
|
-
"@atscript/
|
|
45
|
-
"@atscript/
|
|
44
|
+
"@atscript/typescript": "^0.0.31",
|
|
45
|
+
"@atscript/core": "^0.0.31"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"pub": "pnpm publish --access public",
|