@midwayjs/validate 4.0.0-alpha.1 → 4.0.0-beta.10
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 +1 -1
- package/dist/configuration.js +2 -6
- package/dist/decorator/rule.js +2 -2
- package/dist/decorator/valid.js +1 -2
- package/dist/decorator/validate.js +1 -2
- package/dist/dtoHelper.js +2 -3
- package/dist/pipe.js +6 -1
- package/dist/service.js +6 -5
- package/locales/zh_CN.json +1 -1
- package/package.json +9 -9
package/README.md
CHANGED
package/dist/configuration.js
CHANGED
|
@@ -17,6 +17,8 @@ const i18n = require("@midwayjs/i18n");
|
|
|
17
17
|
const pipe_1 = require("./pipe");
|
|
18
18
|
const constants_1 = require("./constants");
|
|
19
19
|
let ValidateConfiguration = class ValidateConfiguration {
|
|
20
|
+
decoratorService;
|
|
21
|
+
validateService;
|
|
20
22
|
async init() {
|
|
21
23
|
this.decoratorService.registerParameterHandler(constants_1.VALID_KEY, ({ parameterIndex, originParamType, originArgs, metadata }) => {
|
|
22
24
|
if (!metadata.schema) {
|
|
@@ -31,12 +33,6 @@ let ValidateConfiguration = class ValidateConfiguration {
|
|
|
31
33
|
await container.getAsync(pipe_1.ParseBoolPipe);
|
|
32
34
|
await container.getAsync(pipe_1.ParseFloatPipe);
|
|
33
35
|
await container.getAsync(pipe_1.DecoratorValidPipe);
|
|
34
|
-
this.decoratorService.registerParameterHandler(constants_1.VALID_KEY, ({ parameterIndex, originParamType, originArgs, metadata }) => {
|
|
35
|
-
if (!metadata.schema) {
|
|
36
|
-
metadata.schema = this.validateService.getSchema(originParamType);
|
|
37
|
-
}
|
|
38
|
-
return originArgs[parameterIndex];
|
|
39
|
-
});
|
|
40
36
|
// register web param default pipe
|
|
41
37
|
this.decoratorService.registerParameterPipes(core_1.WEB_ROUTER_PARAM_KEY, [
|
|
42
38
|
pipe_1.ValidationPipe,
|
package/dist/decorator/rule.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RuleType =
|
|
3
|
+
exports.RuleType = void 0;
|
|
4
|
+
exports.Rule = Rule;
|
|
4
5
|
const Joi = require("joi");
|
|
5
6
|
exports.RuleType = Joi;
|
|
6
7
|
const core_1 = require("@midwayjs/core");
|
|
@@ -12,5 +13,4 @@ function Rule(rule) {
|
|
|
12
13
|
}
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
|
-
exports.Rule = Rule;
|
|
16
16
|
//# sourceMappingURL=rule.js.map
|
package/dist/decorator/valid.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Valid =
|
|
3
|
+
exports.Valid = Valid;
|
|
4
4
|
const core_1 = require("@midwayjs/core");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
const pipe_1 = require("../pipe");
|
|
@@ -18,5 +18,4 @@ function Valid(schemaOrPipes, pipes) {
|
|
|
18
18
|
pipes: [pipe_1.DecoratorValidPipe, ...pipes],
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
exports.Valid = Valid;
|
|
22
21
|
//# sourceMappingURL=valid.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Validate =
|
|
3
|
+
exports.Validate = Validate;
|
|
4
4
|
const core_1 = require("@midwayjs/core");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
function Validate(options = {}) {
|
|
@@ -8,5 +8,4 @@ function Validate(options = {}) {
|
|
|
8
8
|
core_1.MetadataManager.defineMetadata(constants_1.VALIDATE_KEY, options, target, methodName);
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
exports.Validate = Validate;
|
|
12
11
|
//# sourceMappingURL=validate.js.map
|
package/dist/dtoHelper.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PickDto = PickDto;
|
|
4
|
+
exports.OmitDto = OmitDto;
|
|
4
5
|
const core_1 = require("@midwayjs/core");
|
|
5
6
|
const constants_1 = require("./constants");
|
|
6
7
|
function PickDto(dto, keys) {
|
|
@@ -13,7 +14,6 @@ function PickDto(dto, keys) {
|
|
|
13
14
|
});
|
|
14
15
|
return pickedDto;
|
|
15
16
|
}
|
|
16
|
-
exports.PickDto = PickDto;
|
|
17
17
|
function OmitDto(dto, keys) {
|
|
18
18
|
const pickedDto = function () { };
|
|
19
19
|
pickedDto.prototype = dto.prototype;
|
|
@@ -24,5 +24,4 @@ function OmitDto(dto, keys) {
|
|
|
24
24
|
});
|
|
25
25
|
return pickedDto;
|
|
26
26
|
}
|
|
27
|
-
exports.OmitDto = OmitDto;
|
|
28
27
|
//# sourceMappingURL=dtoHelper.js.map
|
package/dist/pipe.js
CHANGED
|
@@ -16,6 +16,7 @@ const i18n = require("@midwayjs/i18n");
|
|
|
16
16
|
const constants_1 = require("./constants");
|
|
17
17
|
const Joi = require("joi");
|
|
18
18
|
class AbstractValidationPipe {
|
|
19
|
+
validateService;
|
|
19
20
|
validateWithSchema(value, options, schema) {
|
|
20
21
|
const validateOptions = this.parseValidationOptions(options);
|
|
21
22
|
const result = this.validateService.validateWithSchema(schema, value, validateOptions);
|
|
@@ -26,7 +27,10 @@ class AbstractValidationPipe {
|
|
|
26
27
|
}
|
|
27
28
|
validate(value, options) {
|
|
28
29
|
const validateOptions = this.parseValidationOptions(options);
|
|
29
|
-
if (options.metaType.isBaseType
|
|
30
|
+
if (options.metaType.isBaseType ||
|
|
31
|
+
!options.metaType.originDesign ||
|
|
32
|
+
options.metadata?.type === 'files_stream' ||
|
|
33
|
+
options.metadata?.type === 'file_stream') {
|
|
30
34
|
return value;
|
|
31
35
|
}
|
|
32
36
|
const result = this.validateService.validate(options.metaType.originDesign, value, validateOptions);
|
|
@@ -103,6 +107,7 @@ exports.ParseFloatPipe = ParseFloatPipe = __decorate([
|
|
|
103
107
|
(0, core_1.Pipe)()
|
|
104
108
|
], ParseFloatPipe);
|
|
105
109
|
class DefaultValuePipe {
|
|
110
|
+
defaultValue;
|
|
106
111
|
constructor(defaultValue) {
|
|
107
112
|
this.defaultValue = defaultValue;
|
|
108
113
|
}
|
package/dist/service.js
CHANGED
|
@@ -9,7 +9,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.ValidateService = void 0;
|
|
13
|
+
exports.getSchema = getSchema;
|
|
13
14
|
const core_1 = require("@midwayjs/core");
|
|
14
15
|
const DefaultConfig = require("./config/config.default");
|
|
15
16
|
const constants_1 = require("./constants");
|
|
@@ -17,9 +18,10 @@ const Joi = require("joi");
|
|
|
17
18
|
const i18n_1 = require("@midwayjs/i18n");
|
|
18
19
|
const error_1 = require("./error");
|
|
19
20
|
let ValidateService = class ValidateService {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
validateConfig;
|
|
22
|
+
i18nConfig;
|
|
23
|
+
i18nService;
|
|
24
|
+
messages = {};
|
|
23
25
|
async init() {
|
|
24
26
|
const locales = Object.keys(DefaultConfig.i18n.localeTable);
|
|
25
27
|
locales.forEach(locale => {
|
|
@@ -82,5 +84,4 @@ function getSchema(ClzType) {
|
|
|
82
84
|
return Joi.object(rules);
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
|
-
exports.getSchema = getSchema;
|
|
86
87
|
//# sourceMappingURL=service.js.map
|
package/locales/zh_CN.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/validate",
|
|
3
|
-
"version": "4.0.0-
|
|
4
|
-
"description": "Midway Component for
|
|
3
|
+
"version": "4.0.0-beta.10",
|
|
4
|
+
"description": "Midway Component for validation (using @midwayjs/validation first)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -19,18 +19,18 @@
|
|
|
19
19
|
"index.d.ts"
|
|
20
20
|
],
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
22
|
+
"node": ">=20"
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@midwayjs/i18n": "^4.0.0-
|
|
26
|
+
"@midwayjs/i18n": "^4.0.0-beta.10",
|
|
27
27
|
"joi": "17.13.3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@midwayjs/core": "^4.0.0-
|
|
31
|
-
"@midwayjs/express": "^4.0.0-
|
|
32
|
-
"@midwayjs/koa": "^4.0.0-
|
|
33
|
-
"@midwayjs/mock": "^4.0.0-
|
|
30
|
+
"@midwayjs/core": "^4.0.0-beta.10",
|
|
31
|
+
"@midwayjs/express": "^4.0.0-beta.10",
|
|
32
|
+
"@midwayjs/koa": "^4.0.0-beta.10",
|
|
33
|
+
"@midwayjs/mock": "^4.0.0-beta.10"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "1b1856629913703f67304155aaf611ec936a81ac"
|
|
36
36
|
}
|