@midwayjs/validate 4.0.0-beta.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/LICENSE +21 -0
- package/README.md +1 -1
- package/dist/configuration.js +2 -0
- 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/package.json +9 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013 - Now midwayjs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
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) {
|
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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/validate",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
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-beta.
|
|
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-beta.
|
|
31
|
-
"@midwayjs/express": "^4.0.0-beta.
|
|
32
|
-
"@midwayjs/koa": "^4.0.0-beta.
|
|
33
|
-
"@midwayjs/mock": "^4.0.0-beta.
|
|
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
|
}
|