@spinajs/validation 1.0.0 → 1.1.6

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.
@@ -1 +1,9 @@
1
- export {};
1
+ declare const config: {
2
+ validation: {
3
+ allErrors: boolean;
4
+ removeAdditional: boolean;
5
+ useDefaults: boolean;
6
+ coerceTypes: boolean;
7
+ };
8
+ };
9
+ export default config;
@@ -1,15 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const path_1 = require("path");
4
- function dir(path) {
5
- return path_1.resolve(path_1.normalize(path_1.join(__dirname, path)));
6
- }
7
- module.exports = {
8
- system: {
9
- dirs: {
10
- schemas: [dir('./../schemas')],
11
- }
12
- },
3
+ const config = {
13
4
  validation: {
14
5
  // enable all errors on validation, not only first one that occurred
15
6
  allErrors: true,
@@ -21,4 +12,5 @@ module.exports = {
21
12
  coerceTypes: true
22
13
  }
23
14
  };
15
+ exports.default = config;
24
16
  //# sourceMappingURL=validation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/config/validation.ts"],"names":[],"mappings":";;AAAA,+BAAgD;AAEhD,SAAS,GAAG,CAAC,IAAY;IACrB,OAAO,cAAO,CAAC,gBAAS,CAAC,WAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,CAAC,OAAO,GAAG;IACb,MAAM,EAAE;QACJ,IAAI,EAAE;YACF,OAAO,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;SACjC;KACJ;IACD,UAAU,EAAE;QAER,qEAAqE;QACrE,SAAS,EAAE,IAAI;QAEf,mDAAmD;QACnD,gBAAgB,EAAE,IAAI;QAEtB,iCAAiC;QACjC,WAAW,EAAE,IAAI;QAEjB,wHAAwH;QACxH,WAAW,EAAE,IAAI;KACpB;CACJ,CAAA"}
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/config/validation.ts"],"names":[],"mappings":";;AAAA,MAAM,MAAM,GAAG;IACX,UAAU,EAAE;QACR,qEAAqE;QACrE,SAAS,EAAE,IAAI;QAEf,mDAAmD;QACnD,gBAAgB,EAAE,IAAI;QAEtB,iCAAiC;QACjC,WAAW,EAAE,IAAI;QAEjB,wHAAwH;QACxH,WAAW,EAAE,IAAI;KACpB;CACJ,CAAA;AAED,kBAAe,MAAM,CAAC"}
package/lib/decorators.js CHANGED
@@ -10,7 +10,7 @@ exports.SCHEMA_SYMBOL = Symbol('SCHEMA_SYMBOL');
10
10
  */
11
11
  function Schema(schema) {
12
12
  return (target) => {
13
- Reflect.defineMetadata(exports.SCHEMA_SYMBOL, schema, target);
13
+ Reflect.defineMetadata(exports.SCHEMA_SYMBOL, schema, target.prototype || target);
14
14
  };
15
15
  }
16
16
  exports.Schema = Schema;
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AAErD;;;;;GAKG;AACH,SAAgB,MAAM,CAAC,MAAuB;IAC1C,OAAO,CAAC,MAAW,EAAE,EAAE;QACnB,OAAO,CAAC,cAAc,CAAC,qBAAa,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC,CAAC;AACN,CAAC;AAJD,wBAIC"}
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AAErD;;;;;GAKG;AACH,SAAgB,MAAM,CAAC,MAAuB;IAC1C,OAAO,CAAC,MAAW,EAAE,EAAE;QACnB,OAAO,CAAC,cAAc,CAAC,qBAAa,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,CAAC;IAC9E,CAAC,CAAC;AACN,CAAC;AAJD,wBAIC"}
@@ -5,7 +5,7 @@ import { ErrorObject } from "ajv";
5
5
  */
6
6
  export declare class ValidationFailed extends Exception {
7
7
  parameter: any;
8
- constructor(message: string, validationErrors: ValidationError[]);
8
+ constructor(message: string, validationErrors: IValidationError[]);
9
9
  }
10
- export interface ValidationError extends ErrorObject {
10
+ export interface IValidationError extends ErrorObject {
11
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAEhD;;GAEG;AACF,MAAa,gBAAiB,SAAQ,sBAAS;IAG5C,YAAY,OAAe,EAAE,gBAAmC;QAC9D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC;IACpC,CAAC;CACF;AAPF,4CAOE"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAEhD;;GAEG;AACF,MAAa,gBAAiB,SAAQ,sBAAS;IAG5C,YAAY,OAAe,EAAE,gBAAoC;QAC/D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC;IACpC,CAAC;CACF;AAPF,4CAOE"}
package/lib/index.d.ts CHANGED
@@ -1,44 +1,12 @@
1
- import { AsyncModule, IContainer } from "@spinajs/di";
2
- import Ajv from "ajv";
3
- import { Configuration } from "@spinajs/configuration";
4
- import { Log } from "@spinajs/log";
5
- import { ValidationError } from "./exceptions";
6
- export declare class DataValidator extends AsyncModule {
7
- protected Validator: Ajv.Ajv;
8
- protected Configuration: Configuration;
9
- protected Container: IContainer;
10
- protected Log: Log;
11
- resolveAsync(container: IContainer): Promise<void>;
12
- /**
13
- * Tries to validate given data
14
- *
15
- * @param data data to validate. Function will try to extract schema attached to object via @Schema decorator
16
- * @return { array : [boolean, ValidationError[]]} [0] true if data is valid, false otherwise, [1] list of all errors. If
17
- * set in config validation.allErrors is set to false, only firs error is returned
18
- */
19
- tryValidate(data: any): [boolean, ValidationError[]];
20
- /**
21
- * Tries to validate given data
22
- *
23
- * @param {string|object|Boolean} schemaKeyRef key, ref or schema object
24
- * @param {Any} data to be validated
25
- * @return { array : [boolean, ValidationError[]]} [0] true if data is valid, false otherwise, [1] list of all errors. If
26
- * set in config validation.allErrors is set to false, only firs error is returned
27
- */
28
- tryValidate(schema: object | string | boolean, data: any): [boolean, ValidationError[]];
29
- /**
30
- * Validate given data. When failed, exception is thrown
31
- *
32
- * @param data data to validate. Function will try to extract schema attached to object via @Schema decorator
33
- * @throws {InvalidArgumen | ValidationFailed }
34
- */
35
- validate(data: any): void;
36
- /**
37
- * Validate given data
38
- *
39
- * @param {string|object|Boolean} schemaKeyRef key, ref or schema object
40
- * @param {Any} data to be validated
41
- * @throws {InvalidArgumen | ValidationFailed }
42
- */
43
- validate(schema: object | string | boolean, data: any): void;
44
- }
1
+ /**
2
+ * We export default configuration for webpack modules
3
+ * Normally we load configuration from disk via filesystem
4
+ * But webpack is bundlig all files into one.
5
+ *
6
+ * When we export, we can see configuration variable
7
+ * in webpack module cache and webpack config loader can see it
8
+ */
9
+ export * from "./config/validation";
10
+ export * from "./decorators";
11
+ export * from "./exceptions";
12
+ export * from "./validator";
package/lib/index.js CHANGED
@@ -6,130 +6,20 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
6
6
  if (k2 === undefined) k2 = k;
7
7
  o[k2] = m[k];
8
8
  }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
15
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
- 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;
18
- return c > 3 && r && Object.defineProperty(target, key, r), r;
19
- };
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
- __setModuleDefault(result, mod);
25
- return result;
26
- };
27
- var __metadata = (this && this.__metadata) || function (k, v) {
28
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
29
- };
30
- var __importDefault = (this && this.__importDefault) || function (mod) {
31
- return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
32
11
  };
33
12
  Object.defineProperty(exports, "__esModule", { value: true });
34
- exports.DataValidator = void 0;
35
- const di_1 = require("@spinajs/di");
36
- const ajv_1 = __importDefault(require("ajv"));
37
- const configuration_1 = require("@spinajs/configuration");
38
- const fs = __importStar(require("fs"));
39
- const glob = __importStar(require("glob"));
40
- const path = __importStar(require("path"));
41
- const log_1 = require("@spinajs/log");
42
- const exceptions_1 = require("./exceptions");
43
- const exceptions_2 = require("@spinajs/exceptions");
44
- const decorators_1 = require("./decorators");
45
- class DataValidator extends di_1.AsyncModule {
46
- async resolveAsync(container) {
47
- this.Configuration = await container.resolve(configuration_1.Configuration);
48
- this.Container = container;
49
- const ajvConfig = Object.assign({ logger: {
50
- log: this.Log.info.bind(this.Log),
51
- warn: this.Log.warn.bind(this.Log),
52
- error: this.Log.error.bind(this.Log)
53
- } }, this.Configuration.get("validation"));
54
- this.Validator = new ajv_1.default(ajvConfig);
55
- // add $merge & $patch for json schema
56
- require("ajv-merge-patch")(this.Validator);
57
- // add common formats validation eg: date time
58
- require("ajv-formats")(this.Validator);
59
- // add keywords
60
- require("ajv-keywords")(this.Validator);
61
- this.Configuration.get("system.dirs.schemas", [])
62
- .filter(dir => fs.existsSync(dir))
63
- .flatMap((d) => glob.sync(path.join(d, "*.json")))
64
- .map(f => {
65
- return {
66
- schema: require(f),
67
- file: path.basename(f)
68
- };
69
- })
70
- .filter(s => {
71
- const isValid = this.Validator.validateSchema(s.schema);
72
- if (!isValid) {
73
- this.Log.warn(`Schema is not valid %s`, s.file);
74
- return false;
75
- }
76
- return true;
77
- })
78
- .forEach(s => {
79
- var _a;
80
- const schemaId = (_a = s.schema.$id) !== null && _a !== void 0 ? _a : path.basename(s.file);
81
- this.Log.trace(`Added schema ${schemaId}`);
82
- this.Validator.addSchema(s.schema, schemaId);
83
- });
84
- }
85
- tryValidate(schemaOrData, data) {
86
- if (arguments.length === 1) {
87
- const schema = Reflect.getMetadata(decorators_1.SCHEMA_SYMBOL, schemaOrData);
88
- if (!schema) {
89
- return [false, [{
90
- keyword: "empty_schema",
91
- dataPath: "data",
92
- schemaPath: "",
93
- params: "data"
94
- }]];
95
- }
96
- const result = this.Validator.validate(schema, schemaOrData);
97
- if (!result) {
98
- return [false, this.Validator.errors];
99
- }
100
- }
101
- else {
102
- if (!data) {
103
- return [false, [{
104
- keyword: "invalid_argument",
105
- dataPath: "data",
106
- schemaPath: "",
107
- params: "data"
108
- }]];
109
- }
110
- const result = this.Validator.validate(schemaOrData, data);
111
- if (!result) {
112
- return [false, this.Validator.errors];
113
- }
114
- }
115
- }
116
- validate(schemaOrData, data) {
117
- const [isValid, errors] = this.tryValidate(schemaOrData, data);
118
- if (!isValid) {
119
- switch (errors[0].keyword) {
120
- case "invalid_argument":
121
- throw new exceptions_2.InvalidArgument("data is null or undefined");
122
- case "empty_schema":
123
- throw new exceptions_2.InvalidArgument("objects schema is not set");
124
- default:
125
- throw new exceptions_1.ValidationFailed("validation error", errors);
126
- }
127
- }
128
- }
129
- }
130
- __decorate([
131
- log_1.Logger(),
132
- __metadata("design:type", Object)
133
- ], DataValidator.prototype, "Log", void 0);
134
- exports.DataValidator = DataValidator;
13
+ /**
14
+ * We export default configuration for webpack modules
15
+ * Normally we load configuration from disk via filesystem
16
+ * But webpack is bundlig all files into one.
17
+ *
18
+ * When we export, we can see configuration variable
19
+ * in webpack module cache and webpack config loader can see it
20
+ */
21
+ __exportStar(require("./config/validation"), exports);
22
+ __exportStar(require("./decorators"), exports);
23
+ __exportStar(require("./exceptions"), exports);
24
+ __exportStar(require("./validator"), exports);
135
25
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oCAAsD;AACtD,8CAAsB;AACtB,0DAAuD;AACvD,uCAAyB;AACzB,2CAA6B;AAC7B,2CAA6B;AAC7B,sCAA2C;AAC3C,6CAAiE;AACjE,oDAAsD;AACtD,6CAA6C;AAE7C,MAAa,aAAc,SAAQ,gBAAW;IAWnC,KAAK,CAAC,YAAY,CAAC,SAAqB;QAE3C,IAAI,CAAC,aAAa,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,6BAAa,CAAC,CAAC;QAC5D,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,MAAM,SAAS,mBACX,MAAM,EAAE;gBACJ,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;gBACjC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;gBAClC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;aACvC,IACE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAQ,CACjD,CAAA;QAED,IAAI,CAAC,SAAS,GA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OAAO,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAC/D,IAAI,CAAC,OAAO,EAAE;YACV,QAAQ,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE;gBACvB,KAAK,kBAAkB;oBACnB,MAAM,IAAI,4BAAe,CAAC,2BAA2B,CAAC,CAAC;gBAC3D,KAAK,cAAc;oBACf,MAAM,IAAI,4BAAe,CAAC,2BAA2B,CAAC,CAAC;gBAC3D;oBACI,MAAM,IAAI,6BAAgB,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;aAE9D;SACJ;IACL,CAAC;CACJ;AA5IG;IADC,YAAM,EAAE;;0CACU;AATvB,sCAqJC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;GAOG;AACF,sDAAoC;AACrC,+CAA6B;AAC7B,+CAA6B;AAC7B,8CAA4B"}
@@ -0,0 +1,12 @@
1
+ interface ISchema {
2
+ schema: any;
3
+ file?: string;
4
+ }
5
+ export declare abstract class SchemaSource {
6
+ abstract Load(): ISchema[];
7
+ }
8
+ export declare class FileSystemSource extends SchemaSource {
9
+ SchemaDirs: string[];
10
+ Load(): ISchema[];
11
+ }
12
+ export {};
package/lib/sources.js ADDED
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ 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;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ };
20
+ var __importStar = (this && this.__importStar) || function (mod) {
21
+ if (mod && mod.__esModule) return mod;
22
+ var result = {};
23
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
+ __setModuleDefault(result, mod);
25
+ return result;
26
+ };
27
+ var __metadata = (this && this.__metadata) || function (k, v) {
28
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.FileSystemSource = exports.SchemaSource = void 0;
32
+ const lib_1 = require("@spinajs/configuration/lib");
33
+ const di_1 = require("@spinajs/di");
34
+ const log_1 = require("@spinajs/log/lib/log");
35
+ const fs = __importStar(require("fs"));
36
+ const glob = __importStar(require("glob"));
37
+ const path = __importStar(require("path"));
38
+ class SchemaSource {
39
+ }
40
+ exports.SchemaSource = SchemaSource;
41
+ let FileSystemSource = class FileSystemSource extends SchemaSource {
42
+ Load() {
43
+ return this.SchemaDirs.filter(dir => fs.existsSync(dir))
44
+ .flatMap((d) => glob.sync(path.join(d, "/**/*.+(json|js)")))
45
+ .map(f => {
46
+ log_1.Log.trace(`Found schema at: ${f}`, "validation");
47
+ return {
48
+ schema: require(f),
49
+ file: path.basename(f)
50
+ };
51
+ });
52
+ }
53
+ };
54
+ __decorate([
55
+ (0, lib_1.Config)("system.dirs.schemas"),
56
+ __metadata("design:type", Array)
57
+ ], FileSystemSource.prototype, "SchemaDirs", void 0);
58
+ FileSystemSource = __decorate([
59
+ (0, di_1.Injectable)(SchemaSource)
60
+ ], FileSystemSource);
61
+ exports.FileSystemSource = FileSystemSource;
62
+ //# sourceMappingURL=sources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sources.js","sourceRoot":"","sources":["../src/sources.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAoD;AACpD,oCAAyC;AACzC,8CAA2C;AAC3C,uCAAyB;AACzB,2CAA6B;AAC7B,2CAA6B;AAO7B,MAAsB,YAAY;CAEjC;AAFD,oCAEC;AAGD,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,YAAY;IAKvC,IAAI;QACP,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;aACnD,OAAO,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC;aACnE,GAAG,CAAC,CAAC,CAAC,EAAE;YAEL,SAAG,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;YAEjD,OAAO;gBACH,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;gBAClB,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;aACzB,CAAC;QACN,CAAC,CAAC,CAAA;IACV,CAAC;CAEJ,CAAA;AAhBG;IADC,IAAA,YAAM,EAAC,qBAAqB,CAAC;;oDACF;AAHnB,gBAAgB;IAD5B,IAAA,eAAU,EAAC,YAAY,CAAC;GACZ,gBAAgB,CAmB5B;AAnBY,4CAAgB"}
@@ -0,0 +1,52 @@
1
+ import { SyncModule, IContainer } from "@spinajs/di";
2
+ import Ajv from "ajv";
3
+ import { IValidationError } from "./exceptions";
4
+ import { SchemaSource } from "./sources";
5
+ export declare class DataValidator extends SyncModule {
6
+ Options: any;
7
+ protected Sources: SchemaSource[];
8
+ protected Validator: Ajv;
9
+ protected Container: IContainer;
10
+ resolve(container: IContainer): void;
11
+ addSchema(schemaObject: any, identifier: string): void;
12
+ /**
13
+ *
14
+ * Checks if schema is loaded ( from file )
15
+ *
16
+ * @param schemaId schema id to check
17
+ * @returns { boolean } true if schema is loaded, false otherwise
18
+ */
19
+ hasSchema(schemaId: string): boolean;
20
+ /**
21
+ * Tries to validate given data
22
+ *
23
+ * @param data data to validate. Function will try to extract schema attached to object via @Schema decorator
24
+ * @return { array : [boolean, ValidationError[]]} [0] true if data is valid, false otherwise, [1] list of all errors. If
25
+ * set in config validation.allErrors is set to false, only firs error is returned
26
+ */
27
+ tryValidate(data: any): [boolean, IValidationError[]];
28
+ /**
29
+ * Tries to validate given data
30
+ *
31
+ * @param {string|object|Boolean} schemaKeyRef key, ref or schema object
32
+ * @param {Any} data to be validated
33
+ * @return { array : [boolean, ValidationError[]]} [0] true if data is valid, false otherwise, [1] list of all errors. If
34
+ * set in config validation.allErrors is set to false, only firs error is returned
35
+ */
36
+ tryValidate(schema: object | string, data: any): [boolean, IValidationError[]];
37
+ /**
38
+ * Validate given data. When failed, exception is thrown
39
+ *
40
+ * @param data data to validate. Function will try to extract schema attached to object via @Schema decorator
41
+ * @throws {InvalidArgument | ValidationFailed }
42
+ */
43
+ validate(data: any): void;
44
+ /**
45
+ * Validate given data
46
+ *
47
+ * @param {string|object|Boolean} schemaKeyRef key, ref or schema object
48
+ * @param {Any} data to be validated
49
+ * @throws {InvalidArgumen | ValidationFailed }
50
+ */
51
+ validate(schema: object | string, data: any): void;
52
+ }
@@ -0,0 +1,150 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.DataValidator = void 0;
16
+ const di_1 = require("@spinajs/di");
17
+ const ajv_1 = __importDefault(require("ajv"));
18
+ const configuration_1 = require("@spinajs/configuration");
19
+ const exceptions_1 = require("./exceptions");
20
+ const exceptions_2 = require("@spinajs/exceptions");
21
+ const decorators_1 = require("./decorators");
22
+ const log_1 = require("@spinajs/log/lib/log");
23
+ const sources_1 = require("./sources");
24
+ class DataValidator extends di_1.SyncModule {
25
+ resolve(container) {
26
+ this.Sources = container.resolve(Array.ofType(sources_1.SchemaSource));
27
+ if (!this.Sources || this.Sources.length === 0) {
28
+ throw new exceptions_2.InvalidOperation("No schema sources avaible. Register any in DI container");
29
+ }
30
+ const ajvConfig = Object.assign({ logger: {
31
+ log: (msg) => log_1.Log.info(msg, "validation"),
32
+ warn: (msg) => log_1.Log.warn(msg, "validation"),
33
+ error: (msg) => log_1.Log.error(msg, "validation")
34
+ } }, this.Options);
35
+ this.Validator = new ajv_1.default(ajvConfig);
36
+ // add $merge & $patch for json schema
37
+ require("ajv-merge-patch")(this.Validator);
38
+ // add common formats validation eg: date time
39
+ require("ajv-formats")(this.Validator);
40
+ // add keywords
41
+ require("ajv-keywords")(this.Validator);
42
+ this.Sources.map(x => x.Load()).reduce((prev, curr) => {
43
+ return prev.concat(curr);
44
+ }, []).filter(s => {
45
+ // validate schema can throw sometimes
46
+ try {
47
+ const vResult = this.Validator.validateSchema(s.schema, true);
48
+ if (!vResult) {
49
+ log_1.Log.error(`Schema at ${s.file} invalid`, "validator");
50
+ return false;
51
+ }
52
+ return true;
53
+ }
54
+ catch (err) {
55
+ log_1.Log.error(`Schema at ${s.file} invalid, reason: ${err.message}`, "validator");
56
+ return false;
57
+ }
58
+ }).forEach(s => {
59
+ this.addSchema(s.schema, s.schema.$id);
60
+ });
61
+ super.resolve(container);
62
+ }
63
+ addSchema(schemaObject, identifier) {
64
+ if (!this.hasSchema(identifier)) {
65
+ this.Validator.addSchema(schemaObject, identifier);
66
+ log_1.Log.trace(`Schema ${identifier} added !`, "validator");
67
+ }
68
+ }
69
+ /**
70
+ *
71
+ * Checks if schema is loaded ( from file )
72
+ *
73
+ * @param schemaId schema id to check
74
+ * @returns { boolean } true if schema is loaded, false otherwise
75
+ */
76
+ hasSchema(schemaId) {
77
+ return !!this.Validator.getSchema(schemaId);
78
+ }
79
+ tryValidate(schemaOrData, data) {
80
+ var _a, _b;
81
+ if (arguments.length === 1) {
82
+ const schema = Reflect.getMetadata(decorators_1.SCHEMA_SYMBOL, schemaOrData);
83
+ if (!schema) {
84
+ return [false, [{
85
+ keyword: "empty_schema",
86
+ instancePath: "./",
87
+ schemaPath: "",
88
+ params: { "data": "" }
89
+ }]];
90
+ }
91
+ const result = this.Validator.validate(schema, schemaOrData);
92
+ if (!result) {
93
+ return [false, (_a = this.Validator.errors) !== null && _a !== void 0 ? _a : null];
94
+ }
95
+ }
96
+ else {
97
+ if (!data) {
98
+ return [false, [{
99
+ keyword: "invalid_argument",
100
+ instancePath: "./",
101
+ schemaPath: "",
102
+ params: { "data": "" }
103
+ }]];
104
+ }
105
+ let schema = null;
106
+ if (typeof schemaOrData === "object") {
107
+ schema = schemaOrData;
108
+ }
109
+ else if (typeof schemaOrData === 'string') {
110
+ const s = this.Validator.getSchema(schemaOrData);
111
+ schema = s === null || s === void 0 ? void 0 : s.schema;
112
+ }
113
+ else {
114
+ schema = Reflect.getMetadata(decorators_1.SCHEMA_SYMBOL, schemaOrData);
115
+ }
116
+ if (!schema) {
117
+ return [false, [{
118
+ keyword: "empty_schema",
119
+ instancePath: "./",
120
+ schemaPath: "",
121
+ params: { "data": "" }
122
+ }]];
123
+ }
124
+ const result = this.Validator.validate(schema, data);
125
+ if (!result) {
126
+ return [false, (_b = this.Validator.errors) !== null && _b !== void 0 ? _b : null];
127
+ }
128
+ }
129
+ return [true, null];
130
+ }
131
+ validate(schemaOrData, data) {
132
+ const [isValid, errors] = this.tryValidate(schemaOrData, data);
133
+ if (!isValid) {
134
+ switch (errors[0].keyword) {
135
+ case "invalid_argument":
136
+ throw new exceptions_2.InvalidArgument("data is null or undefined");
137
+ case "empty_schema":
138
+ throw new exceptions_2.InvalidArgument("objects schema is not set");
139
+ default:
140
+ throw new exceptions_1.ValidationFailed("validation error", errors);
141
+ }
142
+ }
143
+ }
144
+ }
145
+ __decorate([
146
+ (0, configuration_1.Config)("validation"),
147
+ __metadata("design:type", Object)
148
+ ], DataValidator.prototype, "Options", void 0);
149
+ exports.DataValidator = DataValidator;
150
+ //# sourceMappingURL=validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.js","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oCAAqD;AACrD,8CAAsB;AACtB,0DAAgD;AAChD,6CAAkE;AAClE,oDAAwE;AACxE,6CAA6C;AAC7C,8CAA2C;AAC3C,uCAAyC;AAEzC,MAAa,aAAc,SAAQ,eAAU;IAWlC,OAAO,CAAC,SAAqB;QAEhC,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAY,CAAC,CAAC,CAAC;QAE7D,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YAC5C,MAAM,IAAI,6BAAgB,CAAC,yDAAyD,CAAC,CAAC;SACzF;QAED,MAA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AAM,mCAAI,IAAI,CAAC,CAAA;aAChD;SACJ;QAED,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACxB,CAAC;IAkBM,QAAQ,CAAC,YAA6B,EAAE,IAAU;QACrD,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;QAC/D,IAAI,CAAC,OAAO,EAAE;YACV,QAAQ,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE;gBACvB,KAAK,kBAAkB;oBACnB,MAAM,IAAI,4BAAe,CAAC,2BAA2B,CAAC,CAAC;gBAC3D,KAAK,cAAc;oBACf,MAAM,IAAI,4BAAe,CAAC,2BAA2B,CAAC,CAAC;gBAC3D;oBACI,MAAM,IAAI,6BAAgB,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;aAE9D;SACJ;IACL,CAAC;CACJ;AA1LG;IADC,IAAA,sBAAM,EAAC,YAAY,CAAC;;8CACD;AAHxB,sCA6LC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spinajs/validation",
3
- "version": "1.0.0",
3
+ "version": "1.1.6",
4
4
  "description": "validation library for spinajs framework",
5
5
  "main": "lib/index.js",
6
6
  "private": false,
@@ -12,7 +12,7 @@
12
12
  "prepare": "npm run build",
13
13
  "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
14
14
  "lint": "tslint -p tsconfig.json",
15
- "prepublishOnly": "",
15
+ "prepublishOnly": "npm test && npm run lint",
16
16
  "preversion": "npm run lint",
17
17
  "version": "npm run format && git add -A src",
18
18
  "postversion": "git push && git push --tags"
@@ -36,14 +36,14 @@
36
36
  },
37
37
  "homepage": "https://github.com/spinajs/validation#readme",
38
38
  "dependencies": {
39
- "@spinajs/configuration": "^1.0.16",
40
- "@spinajs/di": "^1.1.0",
41
- "@spinajs/exceptions": "^1.0.4",
42
- "@spinajs/log": "^1.0.10",
43
- "ajv": "^6.12.2",
39
+ "@spinajs/configuration": "^1.1.7",
40
+ "@spinajs/di": "^1.1.7",
41
+ "@spinajs/exceptions": "^1.0.5",
42
+ "@spinajs/log": "^1.1.6",
43
+ "ajv": "^8.8.2",
44
44
  "ajv-formats": "^2.1.1",
45
45
  "ajv-keywords": "^5.1.0",
46
- "ajv-merge-patch": "^4.1.0"
46
+ "ajv-merge-patch": "^5.0.1"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/bunyan": "^1.8.6",
@@ -55,6 +55,7 @@
55
55
  "@types/cors": "^2.8.6",
56
56
  "@types/express": "^4.17.6",
57
57
  "@types/formidable": "^1.0.31",
58
+ "@types/glob": "^7.2.0",
58
59
  "@types/helmet": "^0.0.47",
59
60
  "@types/lodash": "^4.14.136",
60
61
  "@types/luxon": "^2.0.8",
@@ -82,6 +83,6 @@
82
83
  "tslint-config-standard": "^8.0.1",
83
84
  "tslint-no-unused-expression-chai": "^0.1.4",
84
85
  "typedoc": "^0.14.2",
85
- "typescript": "^3.7.3"
86
+ "typescript": "^4.2.3"
86
87
  }
87
88
  }