@atscript/moost-validator 0.1.25 → 0.1.27
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/README.md +4 -4
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +4 -4
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -78,12 +78,12 @@ async create(@Body() dto: CreateUserDto) {}
|
|
|
78
78
|
|
|
79
79
|
## API reference
|
|
80
80
|
|
|
81
|
-
| Export | Type
|
|
82
|
-
| ------------------------------- |
|
|
81
|
+
| Export | Type | Description |
|
|
82
|
+
| ------------------------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
83
83
|
| `validatorPipe(opts?)` | `TPipeFn` | Low‑level factory. Returns a pipe that runs `type.validator(opts).validate(value)` on the argument **if** the type was produced by atscript. Registered with priority `VALIDATE`. |
|
|
84
|
-
| `UseValidatorPipe(opts?)` | `Decorator`
|
|
84
|
+
| `UseValidatorPipe(opts?)` | `Decorator` | Sugar over `validatorPipe`. Apply to a class, method, parameter, or property. |
|
|
85
85
|
| `validationErrorTransform()` | `TInterceptorFn` | Catches `ValidatorError`, wraps it into `HttpError(400)` with `{ message, statusCode, _body }`. Priority `CATCH_ERROR`. |
|
|
86
|
-
| `UseValidationErrorTransform()` | `Decorator`
|
|
86
|
+
| `UseValidationErrorTransform()` | `Decorator` | Sugar over `validationErrorTransform()`. |
|
|
87
87
|
|
|
88
88
|
### `opts` (`Partial<TValidatorOptions>`)
|
|
89
89
|
|
package/dist/index.cjs
CHANGED
|
@@ -38,9 +38,9 @@ const UseValidatorPipe = (opts) => (0, moost.Pipe)(validatorPipe(opts));
|
|
|
38
38
|
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region packages/moost-validator/src/error-transform.ts
|
|
41
|
-
const validationErrorTransform = () => (0, moost.
|
|
42
|
-
after
|
|
43
|
-
|
|
41
|
+
const validationErrorTransform = () => (0, moost.defineInterceptor)({
|
|
42
|
+
after: transformValidationError,
|
|
43
|
+
error: transformValidationError
|
|
44
44
|
}, moost.TInterceptorPriority.CATCH_ERROR);
|
|
45
45
|
/**
|
|
46
46
|
* Internal helper that performs the actual conversion: wraps a
|
package/dist/index.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ declare const UseValidatorPipe: (opts?: Partial<TValidatorOptions>) => ClassDeco
|
|
|
58
58
|
* app.applyGlobalInterceptors(validationErrorTransform());
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
|
-
declare const validationErrorTransform: () => moost.
|
|
61
|
+
declare const validationErrorTransform: () => moost.TInterceptorDef;
|
|
62
62
|
/**
|
|
63
63
|
* Decorator that registers {@link validationErrorTransform} on a controller or
|
|
64
64
|
* route handler.
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ValidatorError, isAnnotatedType } from "@atscript/typescript/utils";
|
|
2
|
-
import { Intercept, Pipe, TInterceptorPriority, TPipePriority,
|
|
2
|
+
import { Intercept, Pipe, TInterceptorPriority, TPipePriority, defineInterceptor, definePipeFn } from "moost";
|
|
3
3
|
import { HttpError } from "@moostjs/event-http";
|
|
4
4
|
|
|
5
5
|
//#region packages/moost-validator/src/as-validator.pipe.ts
|
|
@@ -14,9 +14,9 @@ const UseValidatorPipe = (opts) => Pipe(validatorPipe(opts));
|
|
|
14
14
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region packages/moost-validator/src/error-transform.ts
|
|
17
|
-
const validationErrorTransform = () =>
|
|
18
|
-
after
|
|
19
|
-
|
|
17
|
+
const validationErrorTransform = () => defineInterceptor({
|
|
18
|
+
after: transformValidationError,
|
|
19
|
+
error: transformValidationError
|
|
20
20
|
}, TInterceptorPriority.CATCH_ERROR);
|
|
21
21
|
/**
|
|
22
22
|
* Internal helper that performs the actual conversion: wraps a
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/moost-validator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.27",
|
|
4
4
|
"description": "Validator pipe and utils for Moost.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotations",
|
|
@@ -36,13 +36,15 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {},
|
|
38
38
|
"devDependencies": {
|
|
39
|
+
"@moostjs/event-http": "^0.6.0",
|
|
40
|
+
"moost": "^0.6.0",
|
|
39
41
|
"vitest": "3.2.4"
|
|
40
42
|
},
|
|
41
43
|
"peerDependencies": {
|
|
42
|
-
"@moostjs/event-http": "^0.
|
|
43
|
-
"moost": "^0.
|
|
44
|
-
"@atscript/core": "^0.1.
|
|
45
|
-
"@atscript/typescript": "^0.1.
|
|
44
|
+
"@moostjs/event-http": "^0.6.0",
|
|
45
|
+
"moost": "^0.6.0",
|
|
46
|
+
"@atscript/core": "^0.1.27",
|
|
47
|
+
"@atscript/typescript": "^0.1.27"
|
|
46
48
|
},
|
|
47
49
|
"scripts": {
|
|
48
50
|
"pub": "pnpm publish --access public",
|