@midwayjs/validate 3.0.0-beta.9 → 3.0.3

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.
@@ -0,0 +1,13 @@
1
+ import { ValidateOptions } from '../decorator/validate';
2
+ export declare const validate: ValidateOptions;
3
+ export declare const i18n: {
4
+ localeTable: {
5
+ en_US: {
6
+ validate: any;
7
+ };
8
+ zh_CN: {
9
+ validate: any;
10
+ };
11
+ };
12
+ };
13
+ //# sourceMappingURL=config.default.d.ts.map
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.i18n = exports.validate = void 0;
4
+ exports.validate = {
5
+ validationOptions: {},
6
+ errorStatus: 422,
7
+ };
8
+ exports.i18n = {
9
+ localeTable: {
10
+ en_US: {
11
+ validate: require('../../locales/en_US.json'),
12
+ },
13
+ zh_CN: {
14
+ validate: require('../../locales/zh_CN.json'),
15
+ },
16
+ },
17
+ };
18
+ //# sourceMappingURL=config.default.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.default.js","sourceRoot":"","sources":["../../src/config/config.default.ts"],"names":[],"mappings":";;;AAEa,QAAA,QAAQ,GAAoB;IACvC,iBAAiB,EAAE,EAAE;IACrB,WAAW,EAAE,GAAG;CACjB,CAAC;AAEW,QAAA,IAAI,GAAG;IAClB,WAAW,EAAE;QACX,KAAK,EAAE;YACL,QAAQ,EAAE,OAAO,CAAC,0BAA0B,CAAC;SAC9C;QACD,KAAK,EAAE;YACL,QAAQ,EAAE,OAAO,CAAC,0BAA0B,CAAC;SAC9C;KACF;CACF,CAAC","sourcesContent":["import { ValidateOptions } from '../decorator/validate';\n\nexport const validate: ValidateOptions = {\n validationOptions: {},\n errorStatus: 422,\n};\n\nexport const i18n = {\n localeTable: {\n en_US: {\n validate: require('../../locales/en_US.json'),\n },\n zh_CN: {\n validate: require('../../locales/zh_CN.json'),\n },\n },\n};\n"]}
@@ -1,16 +1,8 @@
1
1
  import { MidwayDecoratorService } from '@midwayjs/core';
2
- import * as Joi from 'joi';
3
- import * as DefaultConfig from './config.default';
4
- export declare class ValidateService {
5
- validateConfig: typeof DefaultConfig.validate;
6
- validate(ClzType: new (...args: any[]) => any, value: any, options?: {
7
- errorStatus?: number;
8
- validateOptions?: Joi.ValidationOptions;
9
- }): Joi.ValidationResult<any>;
10
- }
2
+ import { ValidateService } from './service';
11
3
  export declare class ValidateConfiguration {
12
4
  decoratorService: MidwayDecoratorService;
13
5
  validateService: ValidateService;
14
- init(): Promise<void>;
6
+ onReady(): Promise<void>;
15
7
  }
16
8
  //# sourceMappingURL=configuration.d.ts.map
@@ -9,52 +9,35 @@ 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.ValidateConfiguration = exports.ValidateService = void 0;
12
+ exports.ValidateConfiguration = void 0;
13
13
  const decorator_1 = require("@midwayjs/decorator");
14
14
  const core_1 = require("@midwayjs/core");
15
15
  const constants_1 = require("./constants");
16
- const Joi = require("joi");
17
16
  const util = require("util");
18
- const DefaultConfig = require("./config.default");
17
+ const DefaultConfig = require("./config/config.default");
18
+ const service_1 = require("./service");
19
+ const i18n = require("@midwayjs/i18n");
19
20
  const debug = util.debuglog('midway:debug');
20
- let ValidateService = class ValidateService {
21
- validate(ClzType, value, options) {
22
- var _a, _b;
23
- const rules = (0, decorator_1.getClassExtendedMetadata)(constants_1.RULES_KEY, ClzType);
24
- if (rules) {
25
- const schema = Joi.object(rules);
26
- const result = schema.validate(value, Object.assign(this.validateConfig.validationOptions, (_a = options.validateOptions) !== null && _a !== void 0 ? _a : {}));
27
- if (result.error) {
28
- throw new core_1.MidwayValidationError(result.error.message, (_b = options === null || options === void 0 ? void 0 : options.errorStatus) !== null && _b !== void 0 ? _b : this.validateConfig.errorStatus, result.error);
29
- }
30
- else {
31
- return result;
32
- }
33
- }
34
- }
35
- };
36
- __decorate([
37
- (0, decorator_1.Config)('validate'),
38
- __metadata("design:type", Object)
39
- ], ValidateService.prototype, "validateConfig", void 0);
40
- ValidateService = __decorate([
41
- (0, decorator_1.Provide)(),
42
- (0, decorator_1.Scope)(decorator_1.ScopeEnum.Singleton)
43
- ], ValidateService);
44
- exports.ValidateService = ValidateService;
45
21
  let ValidateConfiguration = class ValidateConfiguration {
46
- async init() {
22
+ async onReady() {
47
23
  debug(`[validate]: Register @validate "${constants_1.VALIDATE_KEY}" handler"`);
48
24
  this.decoratorService.registerMethodHandler(constants_1.VALIDATE_KEY, options => {
25
+ var _a;
49
26
  // get param types from method
50
27
  const paramTypes = (0, decorator_1.getMethodParamTypes)(options.target, options.propertyName);
28
+ const validateOptions = (_a = options.metadata) === null || _a === void 0 ? void 0 : _a.options;
51
29
  // add aspect method
52
30
  return {
53
31
  before: (joinPoint) => {
54
- var _a;
55
32
  for (let i = 0; i < paramTypes.length; i++) {
33
+ if (!validateOptions.locale) {
34
+ const maybeCtx = joinPoint.target[core_1.REQUEST_OBJ_CTX_KEY];
35
+ if (maybeCtx && maybeCtx.getAttr) {
36
+ validateOptions.locale = maybeCtx.getAttr(i18n.I18N_ATTR_KEY);
37
+ }
38
+ }
56
39
  const item = paramTypes[i];
57
- const result = this.validateService.validate(item, joinPoint.args[i], (_a = options.metadata) === null || _a === void 0 ? void 0 : _a.options);
40
+ const result = this.validateService.validate(item, joinPoint.args[i], validateOptions);
58
41
  if (result && result.value) {
59
42
  joinPoint.args[i] = result.value;
60
43
  }
@@ -70,17 +53,12 @@ __decorate([
70
53
  ], ValidateConfiguration.prototype, "decoratorService", void 0);
71
54
  __decorate([
72
55
  (0, decorator_1.Inject)(),
73
- __metadata("design:type", ValidateService)
56
+ __metadata("design:type", service_1.ValidateService)
74
57
  ], ValidateConfiguration.prototype, "validateService", void 0);
75
- __decorate([
76
- (0, decorator_1.Init)(),
77
- __metadata("design:type", Function),
78
- __metadata("design:paramtypes", []),
79
- __metadata("design:returntype", Promise)
80
- ], ValidateConfiguration.prototype, "init", null);
81
58
  ValidateConfiguration = __decorate([
82
59
  (0, decorator_1.Configuration)({
83
60
  namespace: 'validate',
61
+ imports: [i18n],
84
62
  importConfigs: [
85
63
  {
86
64
  default: DefaultConfig,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../src/configuration.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mDAK6B;AAC7B,yCAA6E;AAC7E,2CAA2C;AAC3C,6BAA6B;AAC7B,yDAAyD;AACzD,uCAA4C;AAC5C,uCAAuC;AAEvC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;AAW5C,IAAa,qBAAqB,GAAlC,MAAa,qBAAqB;IAOhC,KAAK,CAAC,OAAO;QACX,KAAK,CAAC,mCAAmC,wBAAY,YAAY,CAAC,CAAC;QACnE,IAAI,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,wBAAY,EAAE,OAAO,CAAC,EAAE;;YAClE,8BAA8B;YAC9B,MAAM,UAAU,GAAG,IAAA,+BAAmB,EACpC,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,YAAY,CACrB,CAAC;YAEF,MAAM,eAAe,GAAG,MAAA,OAAO,CAAC,QAAQ,0CAAE,OAAO,CAAC;YAElD,oBAAoB;YACpB,OAAO;gBACL,MAAM,EAAE,CAAC,SAAoB,EAAE,EAAE;oBAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;wBAC1C,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;4BAC3B,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,0BAAmB,CAAC,CAAC;4BACvD,IAAI,QAAQ,IAAI,QAAQ,CAAC,OAAO,EAAE;gCAChC,eAAe,CAAC,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;6BAC/D;yBACF;wBACD,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;wBAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,CAC1C,IAAI,EACJ,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EACjB,eAAe,CAChB,CAAC;wBACF,IAAI,MAAM,IAAI,MAAM,CAAC,KAAK,EAAE;4BAC1B,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;yBAClC;qBACF;gBACH,CAAC;aACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAxCC;IADC,IAAA,kBAAM,GAAE;8BACS,6BAAsB;+DAAC;AAGzC;IADC,IAAA,kBAAM,GAAE;8BACQ,yBAAe;8DAAC;AALtB,qBAAqB;IATjC,IAAA,yBAAa,EAAC;QACb,SAAS,EAAE,UAAU;QACrB,OAAO,EAAE,CAAC,IAAI,CAAC;QACf,aAAa,EAAE;YACb;gBACE,OAAO,EAAE,aAAa;aACvB;SACF;KACF,CAAC;GACW,qBAAqB,CA0CjC;AA1CY,sDAAqB","sourcesContent":["import {\n Configuration,\n Inject,\n getMethodParamTypes,\n JoinPoint,\n} from '@midwayjs/decorator';\nimport { MidwayDecoratorService, REQUEST_OBJ_CTX_KEY } from '@midwayjs/core';\nimport { VALIDATE_KEY } from './constants';\nimport * as util from 'util';\nimport * as DefaultConfig from './config/config.default';\nimport { ValidateService } from './service';\nimport * as i18n from '@midwayjs/i18n';\n\nconst debug = util.debuglog('midway:debug');\n\n@Configuration({\n namespace: 'validate',\n imports: [i18n],\n importConfigs: [\n {\n default: DefaultConfig,\n },\n ],\n})\nexport class ValidateConfiguration {\n @Inject()\n decoratorService: MidwayDecoratorService;\n\n @Inject()\n validateService: ValidateService;\n\n async onReady() {\n debug(`[validate]: Register @validate \"${VALIDATE_KEY}\" handler\"`);\n this.decoratorService.registerMethodHandler(VALIDATE_KEY, options => {\n // get param types from method\n const paramTypes = getMethodParamTypes(\n options.target,\n options.propertyName\n );\n\n const validateOptions = options.metadata?.options;\n\n // add aspect method\n return {\n before: (joinPoint: JoinPoint) => {\n for (let i = 0; i < paramTypes.length; i++) {\n if (!validateOptions.locale) {\n const maybeCtx = joinPoint.target[REQUEST_OBJ_CTX_KEY];\n if (maybeCtx && maybeCtx.getAttr) {\n validateOptions.locale = maybeCtx.getAttr(i18n.I18N_ATTR_KEY);\n }\n }\n const item = paramTypes[i];\n const result = this.validateService.validate(\n item,\n joinPoint.args[i],\n validateOptions\n );\n if (result && result.value) {\n joinPoint.args[i] = result.value;\n }\n }\n },\n };\n });\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,cAAc,CAAC;AAC3B,QAAA,YAAY,GAAG,iBAAiB,CAAC","sourcesContent":["export const RULES_KEY = 'common:rules';\nexport const VALIDATE_KEY = 'common:validate';\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule.js","sourceRoot":"","sources":["../../src/decorator/rule.ts"],"names":[],"mappings":";;;AAAA,2BAA2B;AAwDX,uBAAQ;AAvDxB,mDAK6B;AAC7B,4CAAyC;AAQzC,SAAgB,IAAI,CAAC,IAAI,EAAE,UAAuB,EAAE,QAAQ,EAAE,IAAI,EAAE;IAClE,OAAO,UAAU,GAAG,IAAI;QACtB,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE;YACX,QAAQ;YACR,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC;YACnC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;gBACvB,IAAI,GAAG,GAAG;qBACP,MAAM,CAAC,IAAA,4BAAgB,EAAC,qBAAS,EAAE,IAAI,CAAC,CAAC;qBACzC,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC3B,IAAI,IAAA,2BAAe,EAAC,MAAM,EAAE,WAAW,CAAC,CAAC,IAAI,KAAK,OAAO,EAAE;oBACzD,IAAI,GAAG,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBAC/B,IAAI,OAAO,CAAC,GAAG,EAAE;wBACf,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;qBAC9B;oBACD,IAAI,OAAO,CAAC,GAAG,EAAE;wBACf,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;qBAC9B;iBACF;gBACD,IAAI,OAAO,CAAC,QAAQ,EAAE;oBACpB,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;iBACxB;aACF;YAED,IAAA,+BAAmB,EAAC,qBAAS,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;SAC3D;aAAM;YACL,OAAO;YACP,MAAM,KAAK,GAAG,IAAA,4BAAgB,EAAC,qBAAS,EAAE,IAAI,CAAC,CAAC;YAChD,IAAI,KAAK,EAAE;gBACT,IAAI,WAAW,GAAG,IAAA,4BAAgB,EAAC,qBAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBACvD,WAAW,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,EAAE,CAAC;gBAChC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;oBAC5B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;wBACtB,WAAW,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;qBACjC;gBACH,CAAC,CAAC,CAAC;gBACH,IAAA,6BAAiB,EAAC,qBAAS,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;aACpD;SACF;IACH,CAAC,CAAC;AACJ,CAAC;AAvCD,oBAuCC","sourcesContent":["import * as joi from 'joi';\nimport {\n attachClassMetadata,\n getClassMetadata,\n getPropertyType,\n saveClassMetadata,\n} from '@midwayjs/decorator';\nimport { RULES_KEY } from '../constants';\n\nexport interface RuleOptions {\n required?: boolean;\n min?: number;\n max?: number;\n}\n\nexport function Rule(rule, options: RuleOptions = { required: true }) {\n return function (...args) {\n if (args[1]) {\n // 函数装饰器\n const [target, propertyKey] = args;\n if (!joi.isSchema(rule)) {\n rule = joi\n .object(getClassMetadata(RULES_KEY, rule))\n .meta({ id: rule.name });\n if (getPropertyType(target, propertyKey).name === 'Array') {\n rule = joi.array().items(rule);\n if (options.min) {\n rule = rule.min(options.min);\n }\n if (options.max) {\n rule = rule.max(options.max);\n }\n }\n if (options.required) {\n rule = rule.required();\n }\n }\n\n attachClassMetadata(RULES_KEY, rule, target, propertyKey);\n } else {\n //类的装饰器\n const rules = getClassMetadata(RULES_KEY, rule);\n if (rules) {\n let currentRule = getClassMetadata(RULES_KEY, args[0]);\n currentRule = currentRule ?? {};\n Object.keys(rules).map(item => {\n if (!currentRule[item]) {\n currentRule[item] = rules[item];\n }\n });\n saveClassMetadata(RULES_KEY, currentRule, args[0]);\n }\n }\n };\n}\n\nexport { joi as RuleType };\n"]}
@@ -1,7 +1,8 @@
1
1
  import * as Joi from 'joi';
2
2
  export interface ValidateOptions {
3
3
  errorStatus?: number;
4
- validateOptions?: Joi.ValidationOptions;
4
+ locale?: string;
5
+ validationOptions?: Joi.ValidationOptions;
5
6
  }
6
7
  export declare function Validate(options?: ValidateOptions): MethodDecorator;
7
8
  //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../src/decorator/validate.ts"],"names":[],"mappings":";;;AAAA,mDAAkE;AAClE,4CAA4C;AAS5C,SAAgB,QAAQ,CAAC,UAA2B,EAAE;IACpD,OAAO,IAAA,uCAA2B,EAAC,wBAAY,EAAE;QAC/C,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAJD,4BAIC","sourcesContent":["import { createCustomMethodDecorator } from '@midwayjs/decorator';\nimport { VALIDATE_KEY } from '../constants';\nimport * as Joi from 'joi';\n\nexport interface ValidateOptions {\n errorStatus?: number;\n locale?: string;\n validationOptions?: Joi.ValidationOptions;\n}\n\nexport function Validate(options: ValidateOptions = {}) {\n return createCustomMethodDecorator(VALIDATE_KEY, {\n options,\n });\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dtoHelper.js","sourceRoot":"","sources":["../src/dtoHelper.ts"],"names":[],"mappings":";;;AAAA,mDAG6B;AAC7B,2CAAwC;AAMxC,SAAgB,OAAO,CACrB,GAAW,EACX,IAAS;IAET,MAAM,SAAS,GAAQ,cAAa,CAAC,CAAC;IACtC,SAAS,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IACpC,MAAM,UAAU,GAAG,IAAA,oCAAwB,EAAC,qBAAS,EAAE,GAAG,CAAC,CAAC;IAC5D,MAAM,UAAU,GAAQ,EAAE,CAAC;IAC3B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACtB,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE;YACnB,UAAU,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;SACnC;KACF;IACD,IAAA,6BAAiB,EAAC,qBAAS,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;IACpD,OAAO,SAA8C,CAAC;AACxD,CAAC;AAfD,0BAeC;AAED,SAAgB,OAAO,CACrB,GAAW,EACX,IAAS;IAET,MAAM,SAAS,GAAQ,cAAa,CAAC,CAAC;IACtC,SAAS,CAAC,SAAS,GAAG,GAAG,CAAC,SAAS,CAAC;IACpC,MAAM,UAAU,GAAG,IAAA,oCAAwB,EAAC,qBAAS,EAAE,GAAG,CAAC,CAAC;IAC5D,MAAM,UAAU,GAAQ,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IACtD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;QACtB,OAAO,UAAU,CAAC,GAAG,CAAC,CAAC;KACxB;IACD,IAAA,6BAAiB,EAAC,qBAAS,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;IACpD,OAAO,SAA8C,CAAC;AACxD,CAAC;AAbD,0BAaC","sourcesContent":["import {\n getClassExtendedMetadata,\n saveClassMetadata,\n} from '@midwayjs/decorator';\nimport { RULES_KEY } from './constants';\n\nexport interface Dto<T> extends Function {\n new (): T;\n}\n\nexport function PickDto<T, K extends keyof T>(\n dto: Dto<T>,\n keys: K[]\n): Dto<Pick<T, typeof keys[number]>> {\n const pickedDto: any = function () {};\n pickedDto.prototype = dto.prototype;\n const fatherRule = getClassExtendedMetadata(RULES_KEY, dto);\n const pickedRule: any = {};\n for (const key of keys) {\n if (fatherRule[key]) {\n pickedRule[key] = fatherRule[key];\n }\n }\n saveClassMetadata(RULES_KEY, pickedRule, pickedDto);\n return pickedDto as Dto<Pick<T, typeof keys[number]>>;\n}\n\nexport function OmitDto<T, K extends keyof T>(\n dto: Dto<T>,\n keys: K[]\n): Dto<Omit<T, typeof keys[number]>> {\n const pickedDto: any = function () {};\n pickedDto.prototype = dto.prototype;\n const fatherRule = getClassExtendedMetadata(RULES_KEY, dto);\n const pickedRule: any = Object.assign({}, fatherRule);\n for (const key of keys) {\n delete pickedRule[key];\n }\n saveClassMetadata(RULES_KEY, pickedRule, pickedDto);\n return pickedDto as Dto<Omit<T, typeof keys[number]>>;\n}\n"]}
@@ -0,0 +1,5 @@
1
+ import { MidwayHttpError } from '@midwayjs/core';
2
+ export declare class MidwayValidationError extends MidwayHttpError {
3
+ constructor(message: any, status: any, cause: any);
4
+ }
5
+ //# sourceMappingURL=error.d.ts.map
package/dist/error.js ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MidwayValidationError = void 0;
4
+ const core_1 = require("@midwayjs/core");
5
+ const ValidateErrorCode = (0, core_1.registerErrorCode)('validate', {
6
+ VALIDATE_FAIL: 10000,
7
+ });
8
+ class MidwayValidationError extends core_1.MidwayHttpError {
9
+ constructor(message, status, cause) {
10
+ super(message, status, ValidateErrorCode.VALIDATE_FAIL, {
11
+ cause,
12
+ });
13
+ }
14
+ }
15
+ exports.MidwayValidationError = MidwayValidationError;
16
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AAAA,yCAAoE;AAEpE,MAAM,iBAAiB,GAAG,IAAA,wBAAiB,EAAC,UAAU,EAAE;IACtD,aAAa,EAAE,KAAK;CACZ,CAAC,CAAC;AAEZ,MAAa,qBAAsB,SAAQ,sBAAe;IACxD,YAAY,OAAO,EAAE,MAAM,EAAE,KAAK;QAChC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,iBAAiB,CAAC,aAAa,EAAE;YACtD,KAAK;SACN,CAAC,CAAC;IACL,CAAC;CACF;AAND,sDAMC","sourcesContent":["import { MidwayHttpError, registerErrorCode } from '@midwayjs/core';\n\nconst ValidateErrorCode = registerErrorCode('validate', {\n VALIDATE_FAIL: 10000,\n} as const);\n\nexport class MidwayValidationError extends MidwayHttpError {\n constructor(message, status, cause) {\n super(message, status, ValidateErrorCode.VALIDATE_FAIL, {\n cause,\n });\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- export { ValidateConfiguration as Configuration, ValidateService, } from './configuration';
1
+ export { ValidateConfiguration as Configuration } from './configuration';
2
2
  export * from './decorator/rule';
3
3
  export * from './decorator/validate';
4
4
  export * from './dtoHelper';
5
+ export * from './service';
6
+ export * from './error';
5
7
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -10,11 +10,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.ValidateService = exports.Configuration = void 0;
13
+ exports.Configuration = void 0;
14
14
  var configuration_1 = require("./configuration");
15
15
  Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return configuration_1.ValidateConfiguration; } });
16
- Object.defineProperty(exports, "ValidateService", { enumerable: true, get: function () { return configuration_1.ValidateService; } });
17
16
  __exportStar(require("./decorator/rule"), exports);
18
17
  __exportStar(require("./decorator/validate"), exports);
19
18
  __exportStar(require("./dtoHelper"), exports);
19
+ __exportStar(require("./service"), exports);
20
+ __exportStar(require("./error"), exports);
20
21
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,iDAAyE;AAAhE,8GAAA,qBAAqB,OAAiB;AAC/C,mDAAiC;AACjC,uDAAqC;AACrC,8CAA4B;AAC5B,4CAA0B;AAC1B,0CAAwB","sourcesContent":["export { ValidateConfiguration as Configuration } from './configuration';\nexport * from './decorator/rule';\nexport * from './decorator/validate';\nexport * from './dtoHelper';\nexport * from './service';\nexport * from './error';\n"]}
@@ -0,0 +1,23 @@
1
+ import * as DefaultConfig from './config/config.default';
2
+ import * as Joi from 'joi';
3
+ import { MidwayI18nServiceSingleton } from '@midwayjs/i18n';
4
+ import { ObjectSchema } from 'joi';
5
+ export declare class ValidateService {
6
+ protected validateConfig: typeof DefaultConfig.validate;
7
+ protected i18nConfig: any;
8
+ protected i18nService: MidwayI18nServiceSingleton;
9
+ protected messages: {};
10
+ protected init(): Promise<void>;
11
+ validate<T extends new (...args: any[]) => any>(ClzType: T, value: any, options?: {
12
+ errorStatus?: number;
13
+ locale?: string;
14
+ validationOptions?: Joi.ValidationOptions;
15
+ }): Joi.ValidationResult<T>;
16
+ validateWithSchema<T>(schema: ObjectSchema<any>, value: any, options?: {
17
+ errorStatus?: number;
18
+ locale?: string;
19
+ validationOptions?: Joi.ValidationOptions;
20
+ }): Joi.ValidationResult<T>;
21
+ getSchema<T extends new (...args: any[]) => any>(ClzType: T): ObjectSchema<any>;
22
+ }
23
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ValidateService = void 0;
13
+ const decorator_1 = require("@midwayjs/decorator");
14
+ const DefaultConfig = require("./config/config.default");
15
+ const constants_1 = require("./constants");
16
+ const Joi = require("joi");
17
+ const i18n_1 = require("@midwayjs/i18n");
18
+ const error_1 = require("./error");
19
+ let ValidateService = class ValidateService {
20
+ constructor() {
21
+ this.messages = {};
22
+ }
23
+ async init() {
24
+ const locales = Object.keys(DefaultConfig.i18n.localeTable);
25
+ locales.forEach(locale => {
26
+ this.messages[(0, i18n_1.formatLocale)(locale)] = Object.fromEntries(this.i18nService.getLocaleMapping(locale, 'validate'));
27
+ });
28
+ }
29
+ validate(ClzType, value, options = {}) {
30
+ var _a, _b, _c;
31
+ options.validationOptions = options.validationOptions || {};
32
+ options.validationOptions.errors = options.validationOptions.errors || {};
33
+ options.validationOptions.errors.language = (0, i18n_1.formatLocale)(this.i18nService.getAvailableLocale(options.validationOptions.errors.language ||
34
+ options.locale ||
35
+ this.i18nConfig.defaultLocale, 'validate'));
36
+ const rules = (0, decorator_1.getClassExtendedMetadata)(constants_1.RULES_KEY, ClzType);
37
+ if (rules) {
38
+ const schema = Joi.object(rules);
39
+ const result = schema.validate(value, Object.assign((_a = this.validateConfig.validationOptions) !== null && _a !== void 0 ? _a : {}, {
40
+ messages: this.messages,
41
+ }, (_b = options.validationOptions) !== null && _b !== void 0 ? _b : {}));
42
+ if (result.error) {
43
+ throw new error_1.MidwayValidationError(result.error.message, (_c = options === null || options === void 0 ? void 0 : options.errorStatus) !== null && _c !== void 0 ? _c : this.validateConfig.errorStatus, result.error);
44
+ }
45
+ else {
46
+ return result;
47
+ }
48
+ }
49
+ }
50
+ validateWithSchema(schema, value, options = {}) {
51
+ var _a, _b, _c;
52
+ options.validationOptions = options.validationOptions || {};
53
+ options.validationOptions.errors = options.validationOptions.errors || {};
54
+ options.validationOptions.errors.language = (0, i18n_1.formatLocale)(this.i18nService.getAvailableLocale(options.validationOptions.errors.language ||
55
+ options.locale ||
56
+ this.i18nConfig.defaultLocale, 'validate'));
57
+ const result = schema.validate(value, Object.assign((_a = this.validateConfig.validationOptions) !== null && _a !== void 0 ? _a : {}, {
58
+ messages: this.messages,
59
+ }, (_b = options.validationOptions) !== null && _b !== void 0 ? _b : {}));
60
+ if (result.error) {
61
+ throw new error_1.MidwayValidationError(result.error.message, (_c = options === null || options === void 0 ? void 0 : options.errorStatus) !== null && _c !== void 0 ? _c : this.validateConfig.errorStatus, result.error);
62
+ }
63
+ else {
64
+ return result;
65
+ }
66
+ }
67
+ getSchema(ClzType) {
68
+ const rules = (0, decorator_1.getClassExtendedMetadata)(constants_1.RULES_KEY, ClzType);
69
+ if (rules) {
70
+ return Joi.object(rules);
71
+ }
72
+ }
73
+ };
74
+ __decorate([
75
+ (0, decorator_1.Config)('validate'),
76
+ __metadata("design:type", Object)
77
+ ], ValidateService.prototype, "validateConfig", void 0);
78
+ __decorate([
79
+ (0, decorator_1.Config)('i18n'),
80
+ __metadata("design:type", Object)
81
+ ], ValidateService.prototype, "i18nConfig", void 0);
82
+ __decorate([
83
+ (0, decorator_1.Inject)(),
84
+ __metadata("design:type", i18n_1.MidwayI18nServiceSingleton)
85
+ ], ValidateService.prototype, "i18nService", void 0);
86
+ __decorate([
87
+ (0, decorator_1.Init)(),
88
+ __metadata("design:type", Function),
89
+ __metadata("design:paramtypes", []),
90
+ __metadata("design:returntype", Promise)
91
+ ], ValidateService.prototype, "init", null);
92
+ ValidateService = __decorate([
93
+ (0, decorator_1.Provide)(),
94
+ (0, decorator_1.Scope)(decorator_1.ScopeEnum.Singleton)
95
+ ], ValidateService);
96
+ exports.ValidateService = ValidateService;
97
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n Config,\n getClassExtendedMetadata,\n Provide,\n Scope,\n ScopeEnum,\n Inject,\n Init,\n} from '@midwayjs/decorator';\nimport * as DefaultConfig from './config/config.default';\nimport { RULES_KEY } from './constants';\nimport * as Joi from 'joi';\nimport { MidwayI18nServiceSingleton, formatLocale } from '@midwayjs/i18n';\nimport { MidwayValidationError } from './error';\nimport { ObjectSchema } from 'joi';\n\n@Provide()\n@Scope(ScopeEnum.Singleton)\nexport class ValidateService {\n @Config('validate')\n protected validateConfig: typeof DefaultConfig.validate;\n\n @Config('i18n')\n protected i18nConfig;\n\n @Inject()\n protected i18nService: MidwayI18nServiceSingleton;\n\n protected messages = {};\n\n @Init()\n protected async init() {\n const locales = Object.keys(DefaultConfig.i18n.localeTable);\n locales.forEach(locale => {\n this.messages[formatLocale(locale)] = Object.fromEntries(\n this.i18nService.getLocaleMapping(locale, 'validate')\n );\n });\n }\n\n public validate<T extends new (...args) => any>(\n ClzType: T,\n value: any,\n options: {\n errorStatus?: number;\n locale?: string;\n validationOptions?: Joi.ValidationOptions;\n } = {}\n ): Joi.ValidationResult<T> {\n options.validationOptions = options.validationOptions || {};\n options.validationOptions.errors = options.validationOptions.errors || {};\n options.validationOptions.errors.language = formatLocale(\n this.i18nService.getAvailableLocale(\n options.validationOptions.errors.language ||\n options.locale ||\n this.i18nConfig.defaultLocale,\n 'validate'\n )\n );\n\n const rules = getClassExtendedMetadata(RULES_KEY, ClzType);\n if (rules) {\n const schema = Joi.object(rules);\n const result = schema.validate(\n value,\n Object.assign(\n this.validateConfig.validationOptions ?? {},\n {\n messages: this.messages,\n },\n options.validationOptions ?? {}\n )\n );\n if (result.error) {\n throw new MidwayValidationError(\n result.error.message,\n options?.errorStatus ?? this.validateConfig.errorStatus,\n result.error\n );\n } else {\n return result;\n }\n }\n }\n\n public validateWithSchema<T>(\n schema: ObjectSchema<any>,\n value: any,\n options: {\n errorStatus?: number;\n locale?: string;\n validationOptions?: Joi.ValidationOptions;\n } = {}\n ): Joi.ValidationResult<T> {\n options.validationOptions = options.validationOptions || {};\n options.validationOptions.errors = options.validationOptions.errors || {};\n options.validationOptions.errors.language = formatLocale(\n this.i18nService.getAvailableLocale(\n options.validationOptions.errors.language ||\n options.locale ||\n this.i18nConfig.defaultLocale,\n 'validate'\n )\n );\n\n const result = schema.validate(\n value,\n Object.assign(\n this.validateConfig.validationOptions ?? {},\n {\n messages: this.messages,\n },\n options.validationOptions ?? {}\n )\n );\n if (result.error) {\n throw new MidwayValidationError(\n result.error.message,\n options?.errorStatus ?? this.validateConfig.errorStatus,\n result.error\n );\n } else {\n return result;\n }\n }\n\n public getSchema<T extends new (...args) => any>(\n ClzType: T\n ): ObjectSchema<any> {\n const rules = getClassExtendedMetadata(RULES_KEY, ClzType);\n if (rules) {\n return Joi.object(rules);\n }\n }\n}\n"]}
@@ -0,0 +1,116 @@
1
+ {
2
+ "alternatives.all": "{{#label}} does not match all of the required types",
3
+ "alternatives.any": "{{#label}} does not match any of the allowed types",
4
+ "alternatives.match": "{{#label}} does not match any of the allowed types",
5
+ "alternatives.one": "{{#label}} matches more than one allowed type",
6
+ "alternatives.types": "{{#label}} must be one of {{#types}}",
7
+ "any.custom": "{{#label}} failed custom validation because {{#error.message}}",
8
+ "any.default": "{{#label}} threw an error when running default method",
9
+ "any.failover": "{{#label}} threw an error when running failover method",
10
+ "any.invalid": "{{#label}} contains an invalid value",
11
+ "any.only": "{{#label}} must be {if(#valids.length == 1, \"\", \"one of \")}{{#valids}}",
12
+ "any.ref": "{{#label}} {{#arg}} references {{:#ref}} which {{#reason}}",
13
+ "any.required": "{{#label}} is required",
14
+ "any.unknown": "{{#label}} is not allowed",
15
+ "array.base": "{{#label}} must be an array",
16
+ "array.excludes": "{{#label}} contains an excluded value",
17
+ "array.hasKnown": "{{#label}} does not contain at least one required match for type {:#patternLabel}",
18
+ "array.hasUnknown": "{{#label}} does not contain at least one required match",
19
+ "array.includes": "{{#label}} does not match any of the allowed types",
20
+ "array.includesRequiredBoth": "{{#label}} does not contain {{#knownMisses}} and {{#unknownMisses}} other required value(s)",
21
+ "array.includesRequiredKnowns": "{{#label}} does not contain {{#knownMisses}}",
22
+ "array.includesRequiredUnknowns": "{{#label}} does not contain {{#unknownMisses}} required value(s)",
23
+ "array.length": "{{#label}} must contain {{#limit}} items",
24
+ "array.max": "{{#label}} must contain less than or equal to {{#limit}} items",
25
+ "array.min": "{{#label}} must contain at least {{#limit}} items",
26
+ "array.orderedLength": "{{#label}} must contain at most {{#limit}} items",
27
+ "array.sort": "{{#label}} must be sorted in {#order} order by {{#by}}",
28
+ "array.sort.mismatching": "{{#label}} cannot be sorted due to mismatching types",
29
+ "array.sort.unsupported": "{{#label}} cannot be sorted due to unsupported type {#type}",
30
+ "array.sparse": "{{#label}} must not be a sparse array item",
31
+ "array.unique": "{{#label}} contains a duplicate value",
32
+ "binary.base": "{{#label}} must be a buffer or a string",
33
+ "binary.length": "{{#label}} must be {{#limit}} bytes",
34
+ "binary.max": "{{#label}} must be less than or equal to {{#limit}} bytes",
35
+ "binary.min": "{{#label}} must be at least {{#limit}} bytes",
36
+ "boolean.base": "{{#label}} must be a boolean",
37
+ "date.base": "{{#label}} must be a valid date",
38
+ "date.format": "{{#label}} must be in {msg(\"date.format.\" + #format) || #format} format",
39
+ "date.greater": "{{#label}} must be greater than {{:#limit}}",
40
+ "date.less": "{{#label}} must be less than {{:#limit}}",
41
+ "date.max": "{{#label}} must be less than or equal to {{:#limit}}",
42
+ "date.min": "{{#label}} must be greater than or equal to {{:#limit}}",
43
+ "date.format.iso": "ISO 8601 date",
44
+ "date.format.javascript": "timestamp or number of milliseconds",
45
+ "date.format.unix": "timestamp or number of seconds",
46
+ "function.arity": "{{#label}} must have an arity of {{#n}}",
47
+ "function.class": "{{#label}} must be a class",
48
+ "function.maxArity": "{{#label}} must have an arity lesser or equal to {{#n}}",
49
+ "function.minArity": "{{#label}} must have an arity greater or equal to {{#n}}",
50
+ "object.and": "{{#label}} contains {{#presentWithLabels}} without its required peers {{#missingWithLabels}}",
51
+ "object.assert": "{{#label}} is invalid because {if(#subject.key, `\"` + #subject.key + `\" failed to ` + (#message || \"pass the assertion test\"), #message || \"the assertion failed\")}",
52
+ "object.base": "{{#label}} must be of type {{#type}}",
53
+ "object.instance": "{{#label}} must be an instance of {{:#type}}",
54
+ "object.length": "{{#label}} must have {{#limit}} key{if(#limit == 1, \"\", \"s\")}",
55
+ "object.max": "{{#label}} must have less than or equal to {{#limit}} key{if(#limit == 1, \"\", \"s\")}",
56
+ "object.min": "{{#label}} must have at least {{#limit}} key{if(#limit == 1, \"\", \"s\")}",
57
+ "object.missing": "{{#label}} must contain at least one of {{#peersWithLabels}}",
58
+ "object.nand": "{{:#mainWithLabel}} must not exist simultaneously with {{#peersWithLabels}}",
59
+ "object.oxor": "{{#label}} contains a conflict between optional exclusive peers {{#peersWithLabels}}",
60
+ "object.pattern.match": "{{#label}} keys failed to match pattern requirements",
61
+ "object.refType": "{{#label}} must be a Joi reference",
62
+ "object.regex": "{{#label}} must be a RegExp object",
63
+ "object.rename.multiple": "{{#label}} cannot rename {{:#from}} because multiple renames are disabled and another key was already renamed to {{:#to}}",
64
+ "object.rename.override": "{{#label}} cannot rename {{:#from}} because override is disabled and target {{:#to}} exists",
65
+ "object.schema": "{{#label}} must be a Joi schema of {{#type}} type",
66
+ "object.unknown": "{{#label}} is not allowed",
67
+ "object.with": "{{:#mainWithLabel}} missing required peer {{:#peerWithLabel}}",
68
+ "object.without": "{{:#mainWithLabel}} conflict with forbidden peer {{:#peerWithLabel}}",
69
+ "object.xor": "{{#label}} contains a conflict between exclusive peers {{#peersWithLabels}}",
70
+ "number.base": "{{#label}} must be a number",
71
+ "number.greater": "{{#label}} must be greater than {{#limit}}",
72
+ "number.infinity": "{{#label}} cannot be infinity",
73
+ "number.integer": "{{#label}} must be an integer",
74
+ "number.less": "{{#label}} must be less than {{#limit}}",
75
+ "number.max": "{{#label}} must be less than or equal to {{#limit}}",
76
+ "number.min": "{{#label}} must be greater than or equal to {{#limit}}",
77
+ "number.multiple": "{{#label}} must be a multiple of {{#multiple}}",
78
+ "number.negative": "{{#label}} must be a negative number",
79
+ "number.port": "{{#label}} must be a valid port",
80
+ "number.positive": "{{#label}} must be a positive number",
81
+ "number.precision": "{{#label}} must have no more than {{#limit}} decimal places",
82
+ "number.unsafe": "{{#label}} must be a safe number",
83
+ "string.alphanum": "{{#label}} must only contain alpha-numeric characters",
84
+ "string.base": "{{#label}} must be a string",
85
+ "string.base64": "{{#label}} must be a valid base64 string",
86
+ "string.creditCard": "{{#label}} must be a credit card",
87
+ "string.dataUri": "{{#label}} must be a valid dataUri string",
88
+ "string.domain": "{{#label}} must contain a valid domain name",
89
+ "string.email": "{{#label}} must be a valid email",
90
+ "string.empty": "{{#label}} is not allowed to be empty",
91
+ "string.guid": "{{#label}} must be a valid GUID",
92
+ "string.hex": "{{#label}} must only contain hexadecimal characters",
93
+ "string.hexAlign": "{{#label}} hex decoded representation must be byte aligned",
94
+ "string.hostname": "{{#label}} must be a valid hostname",
95
+ "string.ip": "{{#label}} must be a valid ip address with a {{#cidr}} CIDR",
96
+ "string.ipVersion": "{{#label}} must be a valid ip address of one of the following versions {{#version}} with a {{#cidr}} CIDR",
97
+ "string.isoDate": "{{#label}} must be in iso format",
98
+ "string.isoDuration": "{{#label}} must be a valid ISO 8601 duration",
99
+ "string.length": "{{#label}} length must be {{#limit}} characters long",
100
+ "string.lowercase": "{{#label}} must only contain lowercase characters",
101
+ "string.max": "{{#label}} length must be less than or equal to {{#limit}} characters long",
102
+ "string.min": "{{#label}} length must be at least {{#limit}} characters long",
103
+ "string.normalize": "{{#label}} must be unicode normalized in the {{#form}} form",
104
+ "string.token": "{{#label}} must only contain alpha-numeric and underscore characters",
105
+ "string.pattern.base": "{{#label}} with value {:[.]} fails to match the required pattern: {{#regex}}",
106
+ "string.pattern.name": "{{#label}} with value {:[.]} fails to match the {{#name}} pattern",
107
+ "string.pattern.invert.base": "{{#label}} with value {:[.]} matches the inverted pattern: {{#regex}}",
108
+ "string.pattern.invert.name": "{{#label}} with value {:[.]} matches the inverted {{#name}} pattern",
109
+ "string.trim": "{{#label}} must not have leading or trailing whitespace",
110
+ "string.uri": "{{#label}} must be a valid uri",
111
+ "string.uriCustomScheme": "{{#label}} must be a valid uri with a scheme matching the {{#scheme}} pattern",
112
+ "string.uriRelativeOnly": "{{#label}} must be a valid relative uri",
113
+ "string.uppercase": "{{#label}} must only contain uppercase characters",
114
+ "symbol.base": "{{#label}} must be a symbol",
115
+ "symbol.map": "{{#label}} must be one of {{#map}}"
116
+ }
@@ -0,0 +1,116 @@
1
+ {
2
+ "alternatives.all": "{{#label}} 不能匹配上所以可选项",
3
+ "alternatives.any": "{{#label}} 不能匹配上任何可选项",
4
+ "alternatives.match": "{{#label}} 不能匹配上任何可选项",
5
+ "alternatives.one": "{{#label}} 匹配超过一个可选项",
6
+ "alternatives.types": "{{#label}} 必须是 {{#types}}",
7
+ "any.custom": "{{#label}} 自定义校验失败,原因为 {{#error.message}}",
8
+ "any.default": "{{#label}} 运行默认函数时出错",
9
+ "any.failover": "{{#label}} 运行 failover 函数时出错",
10
+ "any.invalid": "{{#label}} 不是可选值",
11
+ "any.only": "{{#label}} 必须是 {if(#valids.length == 1, \"\", \"one of \")}{{#valids}}",
12
+ "any.ref": "{{#label}} {{#arg}} 引用 {{:#ref}} 其中 {{#reason}}",
13
+ "any.required": "{{#label}} 是必须的",
14
+ "any.unknown": "{{#label}} 不被允许",
15
+ "array.base": "{{#label}} 必须是数组",
16
+ "array.excludes": "{{#label}} 包含排除的值",
17
+ "array.hasKnown": "{{#label}} 不包含至少一个类型为 {:#patternLabel} 的必选项",
18
+ "array.hasUnknown": "{{#label}} 不包含至少一个必选项",
19
+ "array.includes": "{{#label}} 不能匹配上任何可选项",
20
+ "array.includesRequiredBoth": "{{#label}} 不包含 {{#knownMisses}} 及 {{#unknownMisses}} 个必选项",
21
+ "array.includesRequiredKnowns": "{{#label}} 不包含 {{#knownMisses}} 等必选项",
22
+ "array.includesRequiredUnknowns": "{{#label}} 不包含 {{#unknownMisses}} 个必选项",
23
+ "array.length": "{{#label}} 必须正好包含 {{#limit}} 个成员",
24
+ "array.max": "{{#label}} 必须最多包含 {{#limit}} 个成员",
25
+ "array.min": "{{#label}} 必须至少包含 {{#limit}} 个成员",
26
+ "array.orderedLength": "{{#label}} 必须至少包含 {{#limit}} 个成员",
27
+ "array.sort": "{{#label}} 必须按 {#order} 顺序按 {{#by}} 排序",
28
+ "array.sort.mismatching": "{{#label}} 由于类型不匹配而无法排序",
29
+ "array.sort.unsupported": "{{#label}} 类型 {#type} 不支持排序",
30
+ "array.sparse": "{{#label}} 不能包含未定义成员",
31
+ "array.unique": "{{#label}} 是重复的成员",
32
+ "binary.base": "{{#label}} 必须是一段内容",
33
+ "binary.length": "{{#label}} 必须至少包含 {{#limit}} 个字节",
34
+ "binary.max": "{{#label}} 必须最多包含 {{#limit}} 个字节",
35
+ "binary.min": "{{#label}} 必须至少包含 {{#limit}} 个字节",
36
+ "boolean.base": "{{#label}} 必须是 bool 值",
37
+ "date.base": "{{#label}} 必须是毫秒数或者有效的时间字符串",
38
+ "date.format": "{{#label}} 必须是以下格式的字符串 {msg(\"date.format.\" + #format) || #format}",
39
+ "date.greater": "{{#label}} 必须晚于 {{:#limit}}",
40
+ "date.less": "{{#label}} 必须早于 {{:#limit}}",
41
+ "date.max": "{{#label}} 必须早于 {{:#limit}}",
42
+ "date.min": "{{#label}} 必须晚于 {{:#limit}}",
43
+ "date.format.iso": "必须是有效的\"ISO 8601\"格式的时间",
44
+ "date.format.javascript": "必须是有效的时间戳或者毫秒数",
45
+ "date.format.unix": "必须是有效的时间戳或者秒数",
46
+ "function.arity": "{{#label}} 必须正好拥有 {{#n}} 个参数",
47
+ "function.class": "{{#label}} 必须是对象类",
48
+ "function.maxArity": "{{#label}} 必须最多拥有 {{#n}} 个参数",
49
+ "function.minArity": "{{#label}} 必须至少拥有 {{#n}} 个参数",
50
+ "object.and": "{{#label}} 当前 {{#presentWithLabels}} 需要有对应的 {{#missingWithLabels}}",
51
+ "object.assert": "{{#label}} 无效,原因为 {if(#subject.key, `\"` + #subject.key + `\" failed to ` + (#message || \"pass the assertion test\"), #message || \"the assertion failed\")}",
52
+ "object.base": "{{#label}} 必须是一个对象 {{#type}}",
53
+ "object.instance": "{{#label}} 必须是一个 {{:#type}} 的实例",
54
+ "object.length": "{{#label}} 必须正好包含 {{#limit}} 个子对象",
55
+ "object.max": "{{#label}} 必须最多包含 {{#limit}} 个子对象",
56
+ "object.min": "{{#label}} 必须至少包含 {{#limit}} 个子对象",
57
+ "object.missing": "{{#label}} 没有对应的 {{#peersWithLabels}}",
58
+ "object.nand": "{{:#mainWithLabel}} 不得与 {{#peersWithLabels}} 同时存在",
59
+ "object.oxor": "{{#label}} 和 {{#peerWithLabels}} 有冲突",
60
+ "object.pattern.match": "{{#label}} 键匹配失败",
61
+ "object.refType": "{{#label}} 必须是 Joi 引用",
62
+ "object.regex": "{{#label}} 必须是正则对象",
63
+ "object.rename.multiple": "{{#label}} 无法重命名 {{:#from}} 因为多次重命名被禁用并且另一个键已经重命名为 {{:#to}}",
64
+ "object.rename.override": "{{#label}} 无法重命名 {{:#from}} 因为覆盖被禁用并且目标 {{:#to}} 存在",
65
+ "object.schema": "{{#label}} 必须是 {{#type}} 类型的 Joi Schema",
66
+ "object.unknown": "{{#label}} 不被允许",
67
+ "object.with": "{{:#mainWithLabel}} 缺少必需的对等方 {{:#peerWithLabel}}",
68
+ "object.without": "{{:#mainWithLabel}} 与禁止的节点冲突 {{:#peerWithLabel}}",
69
+ "object.xor": "{{#label}} 包含独占对等体之间的冲突 {{#peersWithLabels}}",
70
+ "number.base": "{{#label}} 必须是数值",
71
+ "number.greater": "{{#label}} 必须大于 {{#limit}}",
72
+ "number.infinity": "{{#label}} 不能是无穷大",
73
+ "number.integer": "{{#label}} 必须是整数",
74
+ "number.less": "{{#label}} 必须小于 {{#limit}}",
75
+ "number.max": "{{#label}} 必须小于或等于 {{#limit}}",
76
+ "number.min": "{{#label}} 必须大于或等于 {{#limit}}",
77
+ "number.multiple": "{{#label}} 必须是 {{#multiple}} 的倍数",
78
+ "number.negative": "{{#label}} 必须是负数",
79
+ "number.port": "{{#label}} 必须是有效的端口号",
80
+ "number.positive": "{{#label}} 必须是正数",
81
+ "number.precision": "{{#label}} 必须有 {{#limit}} 位小数",
82
+ "number.unsafe": "{{#label}} 必须是安全号码",
83
+ "string.alphanum": "{{#label}} must only contain alpha-numeric characters",
84
+ "string.base": "{{#label}} 必须是字符串",
85
+ "string.base64": "{{#label}} 必须是有效的 base64 字符串",
86
+ "string.creditCard": "{{#label}} 必须是有效的信用卡号",
87
+ "string.dataUri": "{{#label}} 必须是有效的 dataUri 字符串",
88
+ "string.domain": "{{#label}} 必须包含有效的域名",
89
+ "string.email": "{{#label}} 必须是有效的电子邮件",
90
+ "string.empty": "{{#label}} 不允许为空",
91
+ "string.guid": "{{#label}} 必须是有效的 GUID",
92
+ "string.hex": "{{#label}} 只能包含十六进制字符",
93
+ "string.hexAlign": "{{#label}} 十六进制解码表示必须字节对齐",
94
+ "string.hostname": "{{#label}} 必须是有效的主机名",
95
+ "string.ip": "{{#label}} 必须是具有 {{#cidr}} CIDR 的有效 IP 地址",
96
+ "string.ipVersion": "{{#label}} 必须是以下版本之一的有效 IP 地址 {{#version}} 和 {{#cidr}} CIDR",
97
+ "string.isoDate": "{{#label}} 必须是 iso 格式",
98
+ "string.isoDuration": "{{#label}} 必须是有效的 ISO 8601 持续时间",
99
+ "string.length": "{{#label}} 长度必须为 {{#limit}} 个字符长",
100
+ "string.lowercase": "{{#label}} 只能包含小写字符",
101
+ "string.max": "{{#label}} 长度必须小于或等于 {{#limit}} 个字符长",
102
+ "string.min": "{{#label}} 长度必须至少为 {{#limit}} 个字符长",
103
+ "string.normalize": "{{#label}} 必须以 {{#form}} 形式进行 unicode 规范化",
104
+ "string.token": "{{#label}} 只能包含字母数字和下划线字符",
105
+ "string.pattern.base": "{{#label}} 的值为 {:[.]} 未能匹配所需的模式:{{#regex}}",
106
+ "string.pattern.name": "{{#label}} 值为 {:[.]} 未能匹配 {{#name}} 模式",
107
+ "string.pattern.invert.base": "{{#label}} 与值 {:[.]} 匹配反转模式:{{#regex}}",
108
+ "string.pattern.invert.name": "{{#label}} 与值 {:[.]} 匹配倒置的 {{#name}} 模式",
109
+ "string.trim": "{{#label}} 不得前后空格",
110
+ "string.uri": "{{#label}} 必须是有效的 uri",
111
+ "string.uriCustomScheme": "{{#label}} 必须是有效的 uri,其方案与 {{#scheme}} 模式匹配",
112
+ "string.uriRelativeOnly": "{{#label}} 必须是有效的相对 uri",
113
+ "string.uppercase": "{{#label}} 只能包含大写字符",
114
+ "symbol.base": "{{#label}} 必须是符号",
115
+ "symbol.map": "{{#label}} 必须是 {{#map}} 之一"
116
+ }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@midwayjs/validate",
3
- "version": "3.0.0-beta.9",
3
+ "version": "3.0.3",
4
4
  "description": "Midway Component for mongoose",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
- "test": "node --require=ts-node/register ../../node_modules/.bin/jest",
10
- "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --coverage --forceExit",
9
+ "test": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand",
10
+ "cov": "node --require=ts-node/register ../../node_modules/.bin/jest --runInBand --coverage --forceExit",
11
11
  "ci": "npm run test"
12
12
  },
13
13
  "keywords": [],
@@ -15,19 +15,24 @@
15
15
  "files": [
16
16
  "dist/**/*.js",
17
17
  "dist/**/*.d.ts",
18
- "index.d.ts"
18
+ "locales",
19
+ "index.d.ts",
20
+ "dist/**/*.js.map"
19
21
  ],
20
22
  "engines": {
21
23
  "node": ">=12"
22
24
  },
23
25
  "license": "MIT",
24
26
  "dependencies": {
27
+ "@midwayjs/i18n": "^3.0.3",
25
28
  "joi": "^17.2.1"
26
29
  },
27
30
  "devDependencies": {
28
- "@midwayjs/core": "^3.0.0-beta.9",
29
- "@midwayjs/decorator": "^3.0.0-beta.9",
30
- "@midwayjs/mock": "^3.0.0-beta.9"
31
+ "@midwayjs/core": "^3.0.2",
32
+ "@midwayjs/decorator": "^3.0.2",
33
+ "@midwayjs/express": "^3.0.2",
34
+ "@midwayjs/koa": "^3.0.3",
35
+ "@midwayjs/mock": "^3.0.2"
31
36
  },
32
- "gitHead": "d23e4a4fee58097b98461625c428a37d55535cec"
37
+ "gitHead": "43a5971b284aa918d22d191236c5664b011f8d87"
33
38
  }
package/CHANGELOG.md DELETED
@@ -1,527 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- # [3.0.0-beta.9](https://github.com/midwayjs/midway/compare/v3.0.0-beta.8...v3.0.0-beta.9) (2021-12-09)
7
-
8
- **Note:** Version bump only for package @midwayjs/validate
9
-
10
-
11
-
12
-
13
-
14
- # [3.0.0-beta.8](https://github.com/midwayjs/midway/compare/v3.0.0-beta.7...v3.0.0-beta.8) (2021-12-08)
15
-
16
- **Note:** Version bump only for package @midwayjs/validate
17
-
18
-
19
-
20
-
21
-
22
- # [3.0.0-beta.7](https://github.com/midwayjs/midway/compare/v3.0.0-beta.6...v3.0.0-beta.7) (2021-12-03)
23
-
24
-
25
- ### Bug Fixes
26
-
27
- * validate typing and config ([#1388](https://github.com/midwayjs/midway/issues/1388)) ([0883569](https://github.com/midwayjs/midway/commit/08835691942183e972359cbaa076db06b6bf85ef))
28
-
29
-
30
-
31
-
32
-
33
- # [3.0.0-beta.6](https://github.com/midwayjs/midway/compare/v3.0.0-beta.5...v3.0.0-beta.6) (2021-11-26)
34
-
35
-
36
- ### Bug Fixes
37
-
38
- * class transformer method missing ([#1387](https://github.com/midwayjs/midway/issues/1387)) ([074e839](https://github.com/midwayjs/midway/commit/074e8393598dc95e2742f735df75a2191c5fe25d))
39
-
40
-
41
-
42
-
43
-
44
- # [3.0.0-beta.5](https://github.com/midwayjs/midway/compare/v3.0.0-beta.4...v3.0.0-beta.5) (2021-11-25)
45
-
46
- **Note:** Version bump only for package @midwayjs/validate
47
-
48
-
49
-
50
-
51
-
52
- # [3.0.0-beta.4](https://github.com/midwayjs/midway/compare/v3.0.0-beta.3...v3.0.0-beta.4) (2021-11-24)
53
-
54
-
55
- ### Features
56
-
57
- * add i18n ([#1375](https://github.com/midwayjs/midway/issues/1375)) ([bffefe0](https://github.com/midwayjs/midway/commit/bffefe07afe45777d49b5a76b9ab17fc2b9d9a55))
58
- * auto transform args to type ([#1372](https://github.com/midwayjs/midway/issues/1372)) ([bb3f7d2](https://github.com/midwayjs/midway/commit/bb3f7d2028a034e1926d9df554849332354c3762))
59
-
60
-
61
-
62
-
63
-
64
- # [3.0.0-beta.3](https://github.com/midwayjs/midway/compare/v3.0.0-beta.2...v3.0.0-beta.3) (2021-11-18)
65
-
66
-
67
- ### Features
68
-
69
- * add component and framework config definition ([#1367](https://github.com/midwayjs/midway/issues/1367)) ([b2fe615](https://github.com/midwayjs/midway/commit/b2fe6157f99659471ff1333eca0b86bb889f61a3))
70
-
71
-
72
-
73
-
74
-
75
- # [3.0.0-beta.2](https://github.com/midwayjs/midway/compare/v3.0.0-beta.1...v3.0.0-beta.2) (2021-11-16)
76
-
77
- **Note:** Version bump only for package @midwayjs/validate
78
-
79
-
80
-
81
-
82
-
83
- # [3.0.0-beta.1](https://github.com/midwayjs/midway/compare/v2.12.4...v3.0.0-beta.1) (2021-11-14)
84
-
85
- **Note:** Version bump only for package @midwayjs/validate
86
-
87
-
88
-
89
-
90
-
91
- ## [2.13.3](https://github.com/midwayjs/midway/compare/v2.13.2...v2.13.3) (2021-09-28)
92
-
93
- **Note:** Version bump only for package @midwayjs/typegoose
94
-
95
-
96
-
97
-
98
-
99
- ## [2.13.2](https://github.com/midwayjs/midway/compare/v2.13.1...v2.13.2) (2021-09-09)
100
-
101
- **Note:** Version bump only for package @midwayjs/typegoose
102
-
103
-
104
-
105
-
106
-
107
- ## [2.13.1](https://github.com/midwayjs/midway/compare/v2.13.0...v2.13.1) (2021-09-08)
108
-
109
- **Note:** Version bump only for package @midwayjs/typegoose
110
-
111
-
112
-
113
-
114
-
115
- # [2.13.0](https://github.com/midwayjs/midway/compare/v2.12.9...v2.13.0) (2021-09-07)
116
-
117
- **Note:** Version bump only for package @midwayjs/typegoose
118
-
119
-
120
-
121
-
122
-
123
- ## [2.12.9](https://github.com/midwayjs/midway/compare/v2.12.8...v2.12.9) (2021-09-01)
124
-
125
- **Note:** Version bump only for package @midwayjs/typegoose
126
-
127
-
128
-
129
-
130
-
131
- ## [2.12.7](https://github.com/midwayjs/midway/compare/v2.12.6...v2.12.7) (2021-08-22)
132
-
133
- **Note:** Version bump only for package @midwayjs/typegoose
134
-
135
-
136
-
137
-
138
-
139
- ## [2.12.5](https://github.com/midwayjs/midway/compare/v2.12.4...v2.12.5) (2021-08-18)
140
-
141
- **Note:** Version bump only for package @midwayjs/typegoose
142
-
143
-
144
-
145
-
146
-
147
- ## [2.12.3](https://github.com/midwayjs/midway/compare/v2.12.2...v2.12.3) (2021-08-09)
148
-
149
- **Note:** Version bump only for package @midwayjs/typegoose
150
-
151
-
152
-
153
-
154
-
155
- ## [2.12.1](https://github.com/midwayjs/midway/compare/v2.12.0...v2.12.1) (2021-08-01)
156
-
157
- **Note:** Version bump only for package @midwayjs/typegoose
158
-
159
-
160
-
161
-
162
-
163
- # [2.12.0](https://github.com/midwayjs/midway/compare/v2.11.7...v2.12.0) (2021-07-30)
164
-
165
- **Note:** Version bump only for package @midwayjs/typegoose
166
-
167
-
168
-
169
-
170
-
171
- ## [2.11.6](https://github.com/midwayjs/midway/compare/v2.11.5...v2.11.6) (2021-07-16)
172
-
173
- **Note:** Version bump only for package @midwayjs/typegoose
174
-
175
-
176
-
177
-
178
-
179
- ## [2.11.5](https://github.com/midwayjs/midway/compare/v2.11.4...v2.11.5) (2021-07-15)
180
-
181
- **Note:** Version bump only for package @midwayjs/typegoose
182
-
183
-
184
-
185
-
186
-
187
- ## [2.11.4](https://github.com/midwayjs/midway/compare/v2.11.3...v2.11.4) (2021-07-06)
188
-
189
- **Note:** Version bump only for package @midwayjs/typegoose
190
-
191
-
192
-
193
-
194
-
195
- ## [2.11.3](https://github.com/midwayjs/midway/compare/v2.11.2...v2.11.3) (2021-07-02)
196
-
197
-
198
- ### Bug Fixes
199
-
200
- * hide real error when user code throw error ([#1128](https://github.com/midwayjs/midway/issues/1128)) ([e728b0b](https://github.com/midwayjs/midway/commit/e728b0b80956c09cfb856ffe082f44fa29cfeb82))
201
-
202
-
203
-
204
-
205
-
206
- ## [2.11.2](https://github.com/midwayjs/midway/compare/v2.11.1...v2.11.2) (2021-06-28)
207
-
208
- **Note:** Version bump only for package @midwayjs/typegoose
209
-
210
-
211
-
212
-
213
-
214
- ## [2.11.1](https://github.com/midwayjs/midway/compare/v2.11.0...v2.11.1) (2021-06-19)
215
-
216
- **Note:** Version bump only for package @midwayjs/typegoose
217
-
218
-
219
-
220
-
221
-
222
- # [2.11.0](https://github.com/midwayjs/midway/compare/v2.10.19...v2.11.0) (2021-06-10)
223
-
224
- **Note:** Version bump only for package @midwayjs/typegoose
225
-
226
-
227
-
228
-
229
-
230
- ## [2.10.18](https://github.com/midwayjs/midway/compare/v2.10.17...v2.10.18) (2021-05-26)
231
-
232
- **Note:** Version bump only for package @midwayjs/typegoose
233
-
234
-
235
-
236
-
237
-
238
- ## [2.10.14](https://github.com/midwayjs/midway/compare/v2.10.13...v2.10.14) (2021-05-11)
239
-
240
- **Note:** Version bump only for package @midwayjs/typegoose
241
-
242
-
243
-
244
-
245
-
246
- ## [2.10.13](https://github.com/midwayjs/midway/compare/v2.10.12...v2.10.13) (2021-05-08)
247
-
248
- **Note:** Version bump only for package @midwayjs/typegoose
249
-
250
-
251
-
252
-
253
-
254
- ## [2.10.12](https://github.com/midwayjs/midway/compare/v2.10.11...v2.10.12) (2021-05-07)
255
-
256
- **Note:** Version bump only for package @midwayjs/typegoose
257
-
258
-
259
-
260
-
261
-
262
- ## [2.10.11](https://github.com/midwayjs/midway/compare/v2.10.10...v2.10.11) (2021-04-29)
263
-
264
- **Note:** Version bump only for package @midwayjs/typegoose
265
-
266
-
267
-
268
-
269
-
270
- ## [2.10.10](https://github.com/midwayjs/midway/compare/v2.10.9...v2.10.10) (2021-04-24)
271
-
272
- **Note:** Version bump only for package @midwayjs/typegoose
273
-
274
-
275
-
276
-
277
-
278
- ## [2.10.9](https://github.com/midwayjs/midway/compare/v2.10.8...v2.10.9) (2021-04-21)
279
-
280
- **Note:** Version bump only for package @midwayjs/typegoose
281
-
282
-
283
-
284
-
285
-
286
- ## [2.10.8](https://github.com/midwayjs/midway/compare/v2.10.7...v2.10.8) (2021-04-21)
287
-
288
- **Note:** Version bump only for package @midwayjs/typegoose
289
-
290
-
291
-
292
-
293
-
294
- ## [2.10.7](https://github.com/midwayjs/midway/compare/v2.10.6...v2.10.7) (2021-04-17)
295
-
296
-
297
- ### Bug Fixes
298
-
299
- * add event name args ([#986](https://github.com/midwayjs/midway/issues/986)) ([bfd8232](https://github.com/midwayjs/midway/commit/bfd82320aee8600d8fa30bd2821a0e68c80fd755))
300
- * format ([#997](https://github.com/midwayjs/midway/issues/997)) ([456cc14](https://github.com/midwayjs/midway/commit/456cc14513bdb000d1aa3130e9719caf7a8a803f))
301
-
302
-
303
- ### Features
304
-
305
- * add midway task component ([#995](https://github.com/midwayjs/midway/issues/995)) ([befb81d](https://github.com/midwayjs/midway/commit/befb81dee90f01a20bba2c1835e8685cf85a76e7))
306
-
307
-
308
-
309
-
310
-
311
- ## [2.10.6](https://github.com/midwayjs/midway/compare/v2.10.5...v2.10.6) (2021-04-14)
312
-
313
- **Note:** Version bump only for package @midwayjs/typegoose
314
-
315
-
316
-
317
-
318
-
319
- ## [2.10.5](https://github.com/midwayjs/midway/compare/v2.10.4...v2.10.5) (2021-04-13)
320
-
321
- **Note:** Version bump only for package @midwayjs/typegoose
322
-
323
-
324
-
325
-
326
-
327
- ## [2.10.4](https://github.com/midwayjs/midway/compare/v2.10.3...v2.10.4) (2021-04-10)
328
-
329
- **Note:** Version bump only for package @midwayjs/typegoose
330
-
331
-
332
-
333
-
334
-
335
- ## [2.10.3](https://github.com/midwayjs/midway/compare/v2.10.2...v2.10.3) (2021-04-07)
336
-
337
- **Note:** Version bump only for package @midwayjs/typegoose
338
-
339
-
340
-
341
-
342
-
343
- ## [2.10.2](https://github.com/midwayjs/midway/compare/v2.10.1...v2.10.2) (2021-04-05)
344
-
345
- **Note:** Version bump only for package @midwayjs/typegoose
346
-
347
-
348
-
349
-
350
-
351
- # [2.10.0](https://github.com/midwayjs/midway/compare/v2.9.3...v2.10.0) (2021-04-02)
352
-
353
- **Note:** Version bump only for package @midwayjs/typegoose
354
-
355
-
356
-
357
-
358
-
359
- ## [2.9.3](https://github.com/midwayjs/midway/compare/v2.9.2...v2.9.3) (2021-03-30)
360
-
361
- **Note:** Version bump only for package @midwayjs/typegoose
362
-
363
-
364
-
365
-
366
-
367
- ## [2.9.2](https://github.com/midwayjs/midway/compare/v2.9.1...v2.9.2) (2021-03-27)
368
-
369
- **Note:** Version bump only for package @midwayjs/typegoose
370
-
371
-
372
-
373
-
374
-
375
- ## [2.9.1](https://github.com/midwayjs/midway/compare/v2.9.0...v2.9.1) (2021-03-24)
376
-
377
- **Note:** Version bump only for package @midwayjs/typegoose
378
-
379
-
380
-
381
-
382
-
383
- # [2.9.0](https://github.com/midwayjs/midway/compare/v2.8.13...v2.9.0) (2021-03-22)
384
-
385
- **Note:** Version bump only for package @midwayjs/typegoose
386
-
387
-
388
-
389
-
390
-
391
- ## [2.8.13](https://github.com/midwayjs/midway/compare/v2.8.12...v2.8.13) (2021-03-17)
392
-
393
- **Note:** Version bump only for package @midwayjs/typegoose
394
-
395
-
396
-
397
-
398
-
399
- ## [2.8.11](https://github.com/midwayjs/midway/compare/v2.8.10...v2.8.11) (2021-03-12)
400
-
401
- **Note:** Version bump only for package @midwayjs/typegoose
402
-
403
-
404
-
405
-
406
-
407
- ## [2.8.9](https://github.com/midwayjs/midway/compare/v2.8.8...v2.8.9) (2021-03-08)
408
-
409
- **Note:** Version bump only for package @midwayjs/typegoose
410
-
411
-
412
-
413
-
414
-
415
- ## [2.8.8](https://github.com/midwayjs/midway/compare/v2.8.7...v2.8.8) (2021-03-06)
416
-
417
- **Note:** Version bump only for package @midwayjs/typegoose
418
-
419
-
420
-
421
-
422
-
423
- ## [2.8.7](https://github.com/midwayjs/midway/compare/v2.8.6...v2.8.7) (2021-03-04)
424
-
425
- **Note:** Version bump only for package @midwayjs/typegoose
426
-
427
-
428
-
429
-
430
-
431
- ## [2.8.6](https://github.com/midwayjs/midway/compare/v2.8.5...v2.8.6) (2021-03-03)
432
-
433
- **Note:** Version bump only for package @midwayjs/typegoose
434
-
435
-
436
-
437
-
438
-
439
- ## [2.8.5](https://github.com/midwayjs/midway/compare/v2.8.4...v2.8.5) (2021-03-03)
440
-
441
- **Note:** Version bump only for package @midwayjs/typegoose
442
-
443
-
444
-
445
-
446
-
447
- ## [2.8.4](https://github.com/midwayjs/midway/compare/v2.8.3...v2.8.4) (2021-03-03)
448
-
449
- **Note:** Version bump only for package @midwayjs/typegoose
450
-
451
-
452
-
453
-
454
-
455
- ## [2.8.3](https://github.com/midwayjs/midway/compare/v2.8.2...v2.8.3) (2021-03-01)
456
-
457
- **Note:** Version bump only for package @midwayjs/typegoose
458
-
459
-
460
-
461
-
462
-
463
- ## [2.8.2](https://github.com/midwayjs/midway/compare/v2.8.0...v2.8.2) (2021-02-27)
464
-
465
- **Note:** Version bump only for package @midwayjs/typegoose
466
-
467
-
468
-
469
-
470
-
471
- # [2.8.0](https://github.com/midwayjs/midway/compare/v2.7.7...v2.8.0) (2021-02-24)
472
-
473
- **Note:** Version bump only for package @midwayjs/typegoose
474
-
475
-
476
-
477
-
478
-
479
- ## [2.7.7](https://github.com/midwayjs/midway/compare/v2.7.6...v2.7.7) (2021-02-20)
480
-
481
- **Note:** Version bump only for package @midwayjs/typegoose
482
-
483
-
484
-
485
-
486
-
487
- ## [2.7.5](https://github.com/midwayjs/midway/compare/v2.7.4...v2.7.5) (2021-02-08)
488
-
489
- **Note:** Version bump only for package @midwayjs/typegoose
490
-
491
-
492
-
493
-
494
-
495
- ## [2.7.3](https://github.com/midwayjs/midway/compare/v2.7.2...v2.7.3) (2021-02-02)
496
-
497
-
498
- ### Bug Fixes
499
-
500
- * egg socket io missing session middleware ([#835](https://github.com/midwayjs/midway/issues/835)) ([6e605a1](https://github.com/midwayjs/midway/commit/6e605a15b64bf51182b393b68d66d0867c571b94))
501
-
502
-
503
-
504
-
505
-
506
- ## [2.7.2](https://github.com/midwayjs/midway/compare/v2.7.1...v2.7.2) (2021-01-28)
507
-
508
- **Note:** Version bump only for package @midwayjs/typegoose
509
-
510
-
511
-
512
-
513
-
514
- ## [2.7.1](https://github.com/midwayjs/midway/compare/v2.7.0...v2.7.1) (2021-01-28)
515
-
516
- **Note:** Version bump only for package @midwayjs/typegoose
517
-
518
-
519
-
520
-
521
-
522
- # [2.7.0](https://github.com/midwayjs/midway/compare/v2.6.13...v2.7.0) (2021-01-27)
523
-
524
-
525
- ### Features
526
-
527
- * support entry file in bootstrap ([#819](https://github.com/midwayjs/midway/issues/819)) ([49a5ff6](https://github.com/midwayjs/midway/commit/49a5ff662134bdd42dc3a80738b44a05138f8f7c))
@@ -1,5 +0,0 @@
1
- export declare const validate: {
2
- validationOptions: {};
3
- errorStatus: number;
4
- };
5
- //# sourceMappingURL=config.default.d.ts.map
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validate = void 0;
4
- exports.validate = {
5
- validationOptions: {},
6
- errorStatus: 422,
7
- };
8
- //# sourceMappingURL=config.default.js.map