@spinajs/validation 2.0.46 → 2.0.51

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.
@@ -2,3 +2,4 @@ import { Bootstrapper } from '@spinajs/di';
2
2
  export declare class ValidatorBootstraper extends Bootstrapper {
3
3
  bootstrap(): void;
4
4
  }
5
+ //# sourceMappingURL=bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAkB,MAAM,aAAa,CAAC;AAG3D,qBACa,oBAAqB,SAAQ,YAAY;IAC7C,SAAS,IAAI,IAAI;CAGzB"}
package/lib/bootstrap.js CHANGED
@@ -1,24 +1,18 @@
1
- "use strict";
2
1
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
2
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
3
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
4
  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
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
6
  };
8
- var __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ValidatorBootstraper = void 0;
13
- const di_1 = require("@spinajs/di");
14
- const validation_1 = __importDefault(require("./schemas/validation"));
15
- let ValidatorBootstraper = class ValidatorBootstraper extends di_1.Bootstrapper {
7
+ import { Bootstrapper, DI, Injectable } from '@spinajs/di';
8
+ import CONFIGURATION_SCHEMA from './schemas/validation.js';
9
+ let ValidatorBootstraper = class ValidatorBootstraper extends Bootstrapper {
16
10
  bootstrap() {
17
- di_1.DI.register(validation_1.default).asValue('__configurationSchema__');
11
+ DI.register(CONFIGURATION_SCHEMA).asValue('__configurationSchema__');
18
12
  }
19
13
  };
20
14
  ValidatorBootstraper = __decorate([
21
- (0, di_1.Injectable)(di_1.Bootstrapper)
15
+ Injectable(Bootstrapper)
22
16
  ], ValidatorBootstraper);
23
- exports.ValidatorBootstraper = ValidatorBootstraper;
17
+ export { ValidatorBootstraper };
24
18
  //# sourceMappingURL=bootstrap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAA2D;AAC3D,sEAAwD;AAGxD,IAAa,oBAAoB,GAAjC,MAAa,oBAAqB,SAAQ,iBAAY;IAC7C,SAAS;QACd,OAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACvE,CAAC;CACF,CAAA;AAJY,oBAAoB;IADhC,IAAA,eAAU,EAAC,iBAAY,CAAC;GACZ,oBAAoB,CAIhC;AAJY,oDAAoB"}
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAGpD,IAAM,oBAAoB,GAA1B,MAAM,oBAAqB,SAAQ,YAAY;IAC7C,SAAS;QACd,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACvE,CAAC;CACF,CAAA;AAJY,oBAAoB;IADhC,UAAU,CAAC,YAAY,CAAC;GACZ,oBAAoB,CAIhC;SAJY,oBAAoB"}
@@ -7,3 +7,4 @@ declare const config: {
7
7
  };
8
8
  };
9
9
  export default config;
10
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/config/validation.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,MAAM;;;;;;;CAcX,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  const config = {
4
2
  validation: {
5
3
  // enable all errors on validation, not only first one that occurred
@@ -12,5 +10,5 @@ const config = {
12
10
  coerceTypes: true,
13
11
  },
14
12
  };
15
- exports.default = config;
13
+ export default config;
16
14
  //# sourceMappingURL=validation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/config/validation.ts"],"names":[],"mappings":";;AAAA,MAAM,MAAM,GAAG;IACb,UAAU,EAAE;QACV,qEAAqE;QACrE,SAAS,EAAE,IAAI;QAEf,mDAAmD;QACnD,gBAAgB,EAAE,IAAI;QAEtB,iCAAiC;QACjC,WAAW,EAAE,IAAI;QAEjB,wHAAwH;QACxH,WAAW,EAAE,IAAI;KAClB;CACF,CAAC;AAEF,kBAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/config/validation.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG;IACb,UAAU,EAAE;QACV,qEAAqE;QACrE,SAAS,EAAE,IAAI;QAEf,mDAAmD;QACnD,gBAAgB,EAAE,IAAI;QAEtB,iCAAiC;QACjC,WAAW,EAAE,IAAI;QAEjB,wHAAwH;QACxH,WAAW,EAAE,IAAI;KAClB;CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -6,3 +6,4 @@ export declare const SCHEMA_SYMBOL: unique symbol;
6
6
  * @param schema - schema for object or schema name
7
7
  */
8
8
  export declare function Schema(schema: object | string): (target: any) => void;
9
+ //# sourceMappingURL=decorators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,eAA0B,CAAC;AAErD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,YAC5B,GAAG,UAGpB"}
package/lib/decorators.js CHANGED
@@ -1,18 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Schema = exports.SCHEMA_SYMBOL = void 0;
4
- exports.SCHEMA_SYMBOL = Symbol('SCHEMA_SYMBOL');
1
+ export const SCHEMA_SYMBOL = Symbol('SCHEMA_SYMBOL');
5
2
  /**
6
3
  *
7
4
  * Add schema for object eg. model or dto.
8
5
  *
9
6
  * @param schema - schema for object or schema name
10
7
  */
11
- function Schema(schema) {
8
+ export function Schema(schema) {
12
9
  return (target) => {
13
- var _a;
14
- Reflect.defineMetadata(exports.SCHEMA_SYMBOL, schema, (_a = target.prototype) !== null && _a !== void 0 ? _a : target);
10
+ Reflect.defineMetadata(SCHEMA_SYMBOL, schema, target.prototype ?? target);
15
11
  };
16
12
  }
17
- exports.Schema = Schema;
18
13
  //# sourceMappingURL=decorators.js.map
@@ -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;IAC5C,OAAO,CAAC,MAAW,EAAE,EAAE;;QACrB,OAAO,CAAC,cAAc,CAAC,qBAAa,EAAE,MAAM,EAAE,MAAA,MAAM,CAAC,SAAS,mCAAI,MAAM,CAAC,CAAC;IAC5E,CAAC,CAAC;AACJ,CAAC;AAJD,wBAIC"}
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AAErD;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,MAAuB;IAC5C,OAAO,CAAC,MAAW,EAAE,EAAE;QACrB,OAAO,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,CAAC;IAC5E,CAAC,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import { Exception } from '@spinajs/exceptions';
1
+ import { Exception } from '../../../exceptions/lib/index.js';
2
2
  import { ErrorObject } from 'ajv';
3
3
  /**
4
4
  * The exception that is thrown when JSON entity is checked against schema and is invalid
@@ -9,3 +9,4 @@ export declare class ValidationFailed extends Exception {
9
9
  }
10
10
  export interface IValidationError extends ErrorObject {
11
11
  }
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAClC;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;IACtC,SAAS,EAAE,GAAG,CAAC;gBAEV,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE;CAIlE;AAGD,MAAM,WAAW,gBAAiB,SAAQ,WAAW;CAAG"}
@@ -1,15 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValidationFailed = void 0;
4
- const exceptions_1 = require("@spinajs/exceptions");
1
+ import { Exception } from '../../../exceptions/lib/index.js';
5
2
  /**
6
3
  * The exception that is thrown when JSON entity is checked against schema and is invalid
7
4
  */
8
- class ValidationFailed extends exceptions_1.Exception {
5
+ export class ValidationFailed extends Exception {
9
6
  constructor(message, validationErrors) {
10
7
  super(message);
11
8
  this.parameter = validationErrors;
12
9
  }
13
10
  }
14
- exports.ValidationFailed = ValidationFailed;
15
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,oDAAgD;AAEhD;;GAEG;AACH,MAAa,gBAAiB,SAAQ,sBAAS;IAG7C,YAAY,OAAe,EAAE,gBAAoC;QAC/D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC;IACpC,CAAC;CACF;AAPD,4CAOC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/exceptions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAG7C,YAAY,OAAe,EAAE,gBAAoC;QAC/D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC;IACpC,CAAC;CACF"}
package/lib/index.d.ts CHANGED
@@ -6,8 +6,9 @@
6
6
  * When we export, we can see configuration variable
7
7
  * in webpack module cache and webpack config loader can see it
8
8
  */
9
- export { default } from './config/validation';
10
- export * from './decorators';
11
- export * from './exceptions';
12
- export * from './sources';
13
- export * from './validator';
9
+ export { default } from './config/validation.js';
10
+ export * from './decorators.js';
11
+ export * from './exceptions/index.js';
12
+ export * from './sources.js';
13
+ export * from './validator.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
package/lib/index.js CHANGED
@@ -1,23 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.default = void 0;
21
1
  /**
22
2
  * We export default configuration for webpack modules
23
3
  * Normally we load configuration from disk via filesystem
@@ -26,10 +6,9 @@ exports.default = void 0;
26
6
  * When we export, we can see configuration variable
27
7
  * in webpack module cache and webpack config loader can see it
28
8
  */
29
- var validation_1 = require("./config/validation");
30
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(validation_1).default; } });
31
- __exportStar(require("./decorators"), exports);
32
- __exportStar(require("./exceptions"), exports);
33
- __exportStar(require("./sources"), exports);
34
- __exportStar(require("./validator"), exports);
9
+ export { default } from './config/validation.js';
10
+ export * from './decorators.js';
11
+ export * from './exceptions/index.js';
12
+ export * from './sources.js';
13
+ export * from './validator.js';
35
14
  //# 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;;;;;;;GAOG;AACH,kDAA8C;AAArC,sHAAA,OAAO,OAAA;AAChB,+CAA6B;AAC7B,+CAA6B;AAC7B,4CAA0B;AAC1B,8CAA4B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
@@ -19,3 +19,4 @@ declare const CONFIGURATION_SCHEMA: {
19
19
  };
20
20
  };
21
21
  export default CONFIGURATION_SCHEMA;
22
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/schemas/validation.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;CAWzB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -1,5 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  const CONFIGURATION_SCHEMA = {
4
2
  $id: 'spinajs/validation.configuration.schema.json',
5
3
  $configurationModule: 'validation',
@@ -12,5 +10,5 @@ const CONFIGURATION_SCHEMA = {
12
10
  coerceTypes: { type: 'boolean' },
13
11
  },
14
12
  };
15
- exports.default = CONFIGURATION_SCHEMA;
13
+ export default CONFIGURATION_SCHEMA;
16
14
  //# sourceMappingURL=validation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/schemas/validation.ts"],"names":[],"mappings":";;AAAA,MAAM,oBAAoB,GAAG;IAC3B,GAAG,EAAE,8CAA8C;IACnD,oBAAoB,EAAE,YAAY;IAClC,WAAW,EAAE,wCAAwC;IACrD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QAC9B,gBAAgB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QACrC,WAAW,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QAChC,WAAW,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KACjC;CACF,CAAC;AAEF,kBAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/schemas/validation.ts"],"names":[],"mappings":"AAAA,MAAM,oBAAoB,GAAG;IAC3B,GAAG,EAAE,8CAA8C;IACnD,oBAAoB,EAAE,YAAY;IAClC,WAAW,EAAE,wCAAwC;IACrD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QAC9B,gBAAgB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QACrC,WAAW,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QAChC,WAAW,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KACjC;CACF,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
package/lib/sources.d.ts CHANGED
@@ -1,5 +1,14 @@
1
- import { ISchema, SchemaSource } from './types';
1
+ import { ISchema, SchemaSource } from './types.js';
2
2
  export declare class FileSystemSource extends SchemaSource {
3
3
  SchemaDirs: string[];
4
- Load(): ISchema[];
4
+ LoadJSSchema(): Promise<{
5
+ schema: any;
6
+ file: string;
7
+ }[]>;
8
+ LoadJSONSchema(): {
9
+ schema: any;
10
+ file: string;
11
+ }[];
12
+ Load(): Promise<ISchema[]>;
5
13
  }
14
+ //# sourceMappingURL=sources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sources.d.ts","sourceRoot":"","sources":["../src/sources.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEnD,qBACa,gBAAiB,SAAQ,YAAY;IAEzC,UAAU,EAAE,MAAM,EAAE,CAAC;IAEf,YAAY;;;;IAuBlB,cAAc;;;;IAaR,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAMxC"}
package/lib/sources.js CHANGED
@@ -1,64 +1,64 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
1
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
2
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
3
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
4
  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;
22
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
23
6
  };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
7
  var __metadata = (this && this.__metadata) || function (k, v) {
32
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
9
  };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.FileSystemSource = void 0;
36
- const configuration_1 = require("@spinajs/configuration");
37
- const di_1 = require("@spinajs/di");
38
- const fs = __importStar(require("fs"));
39
- const glob = __importStar(require("glob"));
40
- const path = __importStar(require("path"));
41
- const types_1 = require("./types");
42
- let FileSystemSource = class FileSystemSource extends types_1.SchemaSource {
43
- Load() {
10
+ import { Config } from '@spinajs/configuration';
11
+ import { Injectable } from '@spinajs/di';
12
+ import * as fs from 'fs';
13
+ import glob from 'glob';
14
+ import * as path from 'path';
15
+ import { SchemaSource } from './types.js';
16
+ let FileSystemSource = class FileSystemSource extends SchemaSource {
17
+ async LoadJSSchema() {
18
+ if (!this.SchemaDirs)
19
+ return [];
20
+ const promises = this.SchemaDirs.filter((dir) => fs.existsSync(dir))
21
+ .flatMap((d) => glob.sync(path.join(d, '/**/*.+(js|cjs)').replace(/\\/g, '/')))
22
+ .map((f) => {
23
+ return import(`file://${f}`).then((result) => {
24
+ return {
25
+ result,
26
+ file: path.basename(f),
27
+ };
28
+ });
29
+ });
30
+ const result = await Promise.all(promises);
31
+ return result.map((x) => {
32
+ return {
33
+ schema: x.result.default,
34
+ file: x.file,
35
+ };
36
+ });
37
+ }
38
+ LoadJSONSchema() {
44
39
  if (!this.SchemaDirs)
45
40
  return [];
46
41
  return this.SchemaDirs.filter((dir) => fs.existsSync(dir))
47
- .flatMap((d) => glob.sync(path.join(d, '/**/*.+(json|js)')))
42
+ .flatMap((d) => glob.sync(path.join(d, '/**/*.+(json)').replace(/\\/g, '/')))
48
43
  .map((f) => {
49
44
  return {
50
- schema: require(f),
45
+ schema: JSON.parse(fs.readFileSync(f, 'utf-8')),
51
46
  file: path.basename(f),
52
47
  };
53
48
  });
54
49
  }
50
+ async Load() {
51
+ const sJS = await this.LoadJSSchema();
52
+ const sJSON = this.LoadJSONSchema();
53
+ return sJS.concat(sJSON);
54
+ }
55
55
  };
56
56
  __decorate([
57
- (0, configuration_1.Config)('system.dirs.schemas'),
57
+ Config('system.dirs.schemas'),
58
58
  __metadata("design:type", Array)
59
59
  ], FileSystemSource.prototype, "SchemaDirs", void 0);
60
60
  FileSystemSource = __decorate([
61
- (0, di_1.Injectable)(types_1.SchemaSource)
61
+ Injectable(SchemaSource)
62
62
  ], FileSystemSource);
63
- exports.FileSystemSource = FileSystemSource;
63
+ export { FileSystemSource };
64
64
  //# sourceMappingURL=sources.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sources.js","sourceRoot":"","sources":["../src/sources.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0DAAgD;AAChD,oCAAyC;AACzC,uCAAyB;AACzB,2CAA6B;AAC7B,2CAA6B;AAC7B,mCAA+D;AAG/D,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,oBAAY;IAIzC,IAAI;QACT,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO,EAAE,CAAC;QAEhC,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;aACvD,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,EAAE;YACT,OAAO;gBACL,MAAM,EAAE,OAAO,CAAC,CAAC,CAAkB;gBACnC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;aACvB,CAAC;QACJ,CAAC,CAAC,CAAC;IACP,CAAC;CACF,CAAA;AAdC;IADC,IAAA,sBAAM,EAAC,qBAAqB,CAAC;;oDACF;AAFjB,gBAAgB;IAD5B,IAAA,eAAU,EAAC,oBAAY,CAAC;GACZ,gBAAgB,CAgB5B;AAhBY,4CAAgB"}
1
+ {"version":3,"file":"sources.js","sourceRoot":"","sources":["../src/sources.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;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AU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;aACvD,OAAO,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;aACpF,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACT,OAAO;gBACL,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;gBAC/C,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;aACvB,CAAC;QACJ,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QACtC,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QAEpC,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;CACF,CAAA;AA7CC;IAAC,MAAM,CAAC,qBAAqB,CAAC;;oDACF;AAFjB,gBAAgB;IAD5B,UAAU,CAAC,YAAY,CAAC;GACZ,gBAAgB,CA8C5B;SA9CY,gBAAgB"}
package/lib/types.d.ts CHANGED
@@ -7,7 +7,7 @@ export interface ISchemaObject {
7
7
  [key: string]: any;
8
8
  }
9
9
  export declare abstract class SchemaSource {
10
- abstract Load(): ISchema[];
10
+ abstract Load(): Promise<ISchema[]>;
11
11
  }
12
12
  export interface IValidationOptions {
13
13
  allErrors: boolean;
@@ -15,3 +15,4 @@ export interface IValidationOptions {
15
15
  useDefaults: boolean;
16
16
  coerceTypes: boolean;
17
17
  }
18
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE,aAAa,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,8BAAsB,YAAY;aAChB,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,kBAAkB;IAEjC,SAAS,EAAE,OAAO,CAAC;IAGnB,gBAAgB,EAAE,OAAO,CAAC;IAG1B,WAAW,EAAE,OAAO,CAAC;IAGrB,WAAW,EAAE,OAAO,CAAC;CACtB"}
package/lib/types.js CHANGED
@@ -1,7 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SchemaSource = void 0;
4
- class SchemaSource {
1
+ export class SchemaSource {
5
2
  }
6
- exports.SchemaSource = SchemaSource;
7
3
  //# sourceMappingURL=types.js.map
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAUA,MAAsB,YAAY;CAEjC;AAFD,oCAEC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAUA,MAAM,OAAgB,YAAY;CAEjC"}
@@ -1,15 +1,15 @@
1
- import { SyncService, Container } from '@spinajs/di';
1
+ import { Container, AsyncService } from '@spinajs/di';
2
2
  import Ajv from 'ajv';
3
- import { IValidationError } from './exceptions';
4
- import { IValidationOptions, SchemaSource } from './types';
3
+ import { IValidationError } from './exceptions/index.js';
4
+ import { IValidationOptions, SchemaSource } from './types.js';
5
5
  import { ILog } from '@spinajs/log';
6
- export declare class DataValidator extends SyncService {
6
+ export declare class DataValidator extends AsyncService {
7
7
  Options: IValidationOptions;
8
8
  protected Sources: SchemaSource[];
9
9
  protected Log: ILog;
10
- protected Validator: Ajv;
10
+ protected Validator: Ajv.default;
11
11
  protected Container: Container;
12
- resolve(): void;
12
+ resolve(): Promise<void>;
13
13
  addSchema(schemaObject: object, identifier: string): void;
14
14
  /**
15
15
  *
@@ -49,3 +49,4 @@ export declare class DataValidator extends SyncService {
49
49
  */
50
50
  validate(schema: object | string, data: object): void;
51
51
  }
52
+ //# sourceMappingURL=validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,gBAAgB,EAAoB,MAAM,uBAAuB,CAAC;AAG3E,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAiB,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAU,IAAI,EAAE,MAAM,cAAc,CAAC;AAM5C,qBAAa,aAAc,SAAQ,YAAY;IAEtC,OAAO,EAAE,kBAAkB,CAAC;IAGnC,SAAS,CAAC,OAAO,EAAE,YAAY,EAAE,CAAC;IAGlC,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC;IAEpB,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC;IAGjC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC;IAElB,OAAO;IAwDb,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAOzD;;;;;;OAMG;IACI,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAI3C;;;;;OAKG;IACI,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC/D;;;;;OAKG;IACI,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,OAAO,EAAE,gBAAgB,EAAE,CAAC;IA2BxF;;;;;OAKG;IACI,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAEnC;;;;;;OAMG;IACI,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAc7D"}
package/lib/validator.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
2
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
3
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -8,37 +7,41 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
7
  var __metadata = (this && this.__metadata) || function (k, v) {
9
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
9
  };
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 types_1 = require("./types");
23
- const log_1 = require("@spinajs/log");
24
- class DataValidator extends di_1.SyncService {
25
- resolve() {
10
+ import { Autoinject, Container, AsyncService } from '@spinajs/di';
11
+ import Ajv from 'ajv';
12
+ import { Config } from '@spinajs/configuration';
13
+ import { ValidationFailed } from './exceptions/index.js';
14
+ import { InvalidArgument, InvalidOperation } from '../../exceptions/lib/index.js';
15
+ import { SCHEMA_SYMBOL } from './decorators.js';
16
+ import { SchemaSource } from './types.js';
17
+ import { Logger } from '@spinajs/log';
18
+ import { default as ajvMergePath } from 'ajv-merge-patch';
19
+ import { default as ajvFormats } from 'ajv-formats';
20
+ import { default as ajvKeywords } from 'ajv-keywords';
21
+ export class DataValidator extends AsyncService {
22
+ async resolve() {
26
23
  if (!this.Sources || this.Sources.length === 0) {
27
- throw new exceptions_2.InvalidOperation('No schema sources avaible. Register any in DI container');
24
+ throw new InvalidOperation('No schema sources avaible. Register any in DI container');
28
25
  }
29
- const ajvConfig = Object.assign(Object.assign({ logger: {
26
+ const ajvConfig = {
27
+ logger: {
30
28
  log: (msg) => this.Log.info(msg),
31
29
  warn: (msg) => this.Log.warn(msg),
32
30
  error: (msg) => this.Log.error(msg),
33
- } }, this.Options), { $data: true });
34
- this.Validator = new ajv_1.default(ajvConfig);
31
+ },
32
+ ...this.Options,
33
+ $data: true,
34
+ };
35
+ this.Validator = new Ajv.default(ajvConfig);
35
36
  // add $merge & $patch for json schema
36
- require('ajv-merge-patch')(this.Validator);
37
+ ajvMergePath(this.Validator);
37
38
  // add common formats validation eg: date time
38
- require('ajv-formats')(this.Validator);
39
+ ajvFormats.default(this.Validator);
39
40
  // add keywords
40
- require('ajv-keywords')(this.Validator);
41
- this.Sources.map((x) => x.Load())
41
+ ajvKeywords.default(this.Validator);
42
+ const pSources = this.Sources.map((x) => x.Load());
43
+ const result = await Promise.all(pSources);
44
+ result
42
45
  .reduce((prev, curr) => {
43
46
  return prev.concat(curr);
44
47
  }, [])
@@ -79,10 +82,9 @@ class DataValidator extends di_1.SyncService {
79
82
  return !!this.Validator.getSchema(schemaId);
80
83
  }
81
84
  tryValidate(schemaOrData, data) {
82
- var _a, _b, _c;
83
85
  let schema = null;
84
86
  if (data === null || data === undefined) {
85
- schema = Reflect.getMetadata(decorators_1.SCHEMA_SYMBOL, schemaOrData);
87
+ schema = Reflect.getMetadata(SCHEMA_SYMBOL, schemaOrData);
86
88
  }
87
89
  else {
88
90
  if (typeof schemaOrData === 'object') {
@@ -90,16 +92,16 @@ class DataValidator extends di_1.SyncService {
90
92
  }
91
93
  else if (typeof schemaOrData === 'string') {
92
94
  /* eslint-disable */
93
- schema = (_b = (_a = this.Validator.getSchema(schemaOrData)) === null || _a === void 0 ? void 0 : _a.schema) !== null && _b !== void 0 ? _b : null;
95
+ schema = this.Validator.getSchema(schemaOrData)?.schema ?? null;
94
96
  }
95
97
  else {
96
- schema = Reflect.getMetadata(decorators_1.SCHEMA_SYMBOL, schemaOrData);
98
+ schema = Reflect.getMetadata(SCHEMA_SYMBOL, schemaOrData);
97
99
  }
98
100
  }
99
101
  if (schema) {
100
102
  const result = this.Validator.validate(schema, data !== null && data !== undefined ? data : schemaOrData);
101
103
  if (!result) {
102
- return [false, (_c = this.Validator.errors) !== null && _c !== void 0 ? _c : null];
104
+ return [false, this.Validator.errors ?? null];
103
105
  }
104
106
  }
105
107
  return [true, null];
@@ -109,30 +111,29 @@ class DataValidator extends di_1.SyncService {
109
111
  if (!isValid) {
110
112
  switch (errors[0].keyword) {
111
113
  case 'invalid_argument':
112
- throw new exceptions_2.InvalidArgument('data is null or undefined');
114
+ throw new InvalidArgument('data is null or undefined');
113
115
  case 'empty_schema':
114
- throw new exceptions_2.InvalidArgument('objects schema is not set');
116
+ throw new InvalidArgument('objects schema is not set');
115
117
  default:
116
- throw new exceptions_1.ValidationFailed('validation error', errors);
118
+ throw new ValidationFailed('validation error', errors);
117
119
  }
118
120
  }
119
121
  }
120
122
  }
121
123
  __decorate([
122
- (0, configuration_1.Config)('validation'),
124
+ Config('validation'),
123
125
  __metadata("design:type", Object)
124
126
  ], DataValidator.prototype, "Options", void 0);
125
127
  __decorate([
126
- (0, di_1.Autoinject)(types_1.SchemaSource),
128
+ Autoinject(SchemaSource),
127
129
  __metadata("design:type", Array)
128
130
  ], DataValidator.prototype, "Sources", void 0);
129
131
  __decorate([
130
- (0, log_1.Logger)('validation'),
132
+ Logger('validation'),
131
133
  __metadata("design:type", Object)
132
134
  ], DataValidator.prototype, "Log", void 0);
133
135
  __decorate([
134
- (0, di_1.Autoinject)(),
135
- __metadata("design:type", di_1.Container)
136
+ Autoinject(),
137
+ __metadata("design:type", Container)
136
138
  ], DataValidator.prototype, "Container", void 0);
137
- exports.DataValidator = DataValidator;
138
139
  //# sourceMappingURL=validator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validator.js","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oCAAiE;AACjE,8CAAsB;AACtB,0DAAgD;AAChD,6CAAkE;AAClE,oDAAwE;AACxE,6CAA6C;AAC7C,mCAA0E;AAC1E,sCAA4C;AAE5C,MAAa,aAAc,SAAQ,gBAAW;IAerC,OAAO;QACZ,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9C,MAAM,IAAI,6BAAgB,CAAC,yDAAyD,CAAC,CAAC;SACvF;QAED,MAAM,SAAS,iCACb,MAAM,EAAE;gBACN,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;gBACxC,IAAI,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;gBACzC,KAAK,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC;aAC5C,IACE,IAAI,CAAC,OAAO,KACf,KAAK,EAAE,IAAI,GACZ,CAAC;QAEF,IAAI,CAAC,SAAS,GAAG,IAAI,aAAG,CAAC,SAAS,CAAC,CAAC;QAEpC,sCAAsC;QACtC,OAAO,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAE3C,8CAA8C;QAC9C,OAAO,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEvC,eAAe;QACf,OAAO,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,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O,EAAE;gBACzB,KAAK,kBAAkB;oBACrB,MAAM,IAAI,eAAe,CAAC,2BAA2B,CAAC,CAAC;gBACzD,KAAK,cAAc;oBACjB,MAAM,IAAI,eAAe,CAAC,2BAA2B,CAAC,CAAC;gBACzD;oBACE,MAAM,IAAI,gBAAgB,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;aAC1D;SACF;IACH,CAAC;CACF;AA7JC;IAAC,MAAM,CAAC,YAAY,CAAC;;8CACc;AAEnC;IAAC,UAAU,CAAC,YAAY,CAAC;;8CACS;AAElC;IAAC,MAAM,CAAC,YAAY,CAAC;;0CACD;AAIpB;IAAC,UAAU,EAAE;8BACQ,SAAS;gDAAC"}
package/package.json CHANGED
@@ -1,52 +1,55 @@
1
- {
2
- "name": "@spinajs/validation",
3
- "version": "2.0.46",
4
- "description": "validation library for spinajs framework",
5
- "main": "lib/index.js",
6
- "private": false,
7
- "scripts": {
8
- "test": "ts-mocha -p tsconfig.json test/**/*.test.ts",
9
- "coverage": "nyc npm run test",
10
- "build-docs": "rimraf docs && typedoc --options typedoc.json src/",
11
- "build": "npm run clean && npm run compile",
12
- "compile": "tsc -p tsconfig.build.json",
13
- "prepare": "npm run build",
14
- "clean": "",
15
- "format": "prettier --write \"src/**/*.ts\"",
16
- "lint": "eslint -c .eslintrc.js --ext .ts src",
17
- "prepublishOnly": "npm test && npm run lint",
18
- "preversion": "npm run lint",
19
- "version": "npm run format && git add -A src",
20
- "postversion": "git push && git push --tags"
21
- },
22
- "files": [
23
- "lib/**/*"
24
- ],
25
- "repository": {
26
- "type": "git",
27
- "url": "git+https://github.com/spinajs/validation.git"
28
- },
29
- "keywords": [
30
- "spinajs",
31
- "validation",
32
- "schema"
33
- ],
34
- "author": "SpinaJS <spinajs@coderush.pl> (https://github.com/spinajs/core)",
35
- "license": "MIT",
36
- "bugs": {
37
- "url": "https://github.com/spinajs/validation/issues"
38
- },
39
- "homepage": "https://github.com/spinajs/validation#readme",
40
- "dependencies": {
41
- "@spinajs/configuration": "^2.0.46",
42
- "@spinajs/di": "^2.0.46",
43
- "@spinajs/exceptions": "^2.0.39",
44
- "@spinajs/log": "^2.0.46",
45
- "ajv": "^8.11.0",
46
- "ajv-formats": "^2.1.1",
47
- "ajv-keywords": "^5.1.0",
48
- "ajv-merge-patch": "^5.0.1",
49
- "lodash": "^4.17.21"
50
- },
51
- "gitHead": "bd560afd6c9a156071102cc6b4f36115b5498e9d"
52
- }
1
+ {
2
+ "name": "@spinajs/validation",
3
+ "version": "2.0.51",
4
+ "description": "validation library for spinajs framework",
5
+ "exports": "./lib/index.js",
6
+ "type": "module",
7
+ "private": false,
8
+ "engines": {
9
+ "node": ">=16.11"
10
+ },
11
+ "scripts": {
12
+ "build": "npm run clean && npm run compile",
13
+ "compile": "tsc -b tsconfig.json",
14
+ "rimraf": "./node_modules/rimraf/bin.js",
15
+ "clean": "rimraf lib/ && rimraf tsconfig.tsbuildinfo",
16
+ "test": "ts-mocha -p tsconfig.json test/**/*.test.ts",
17
+ "coverage": "nyc npm run test",
18
+ "build-docs": "rimraf docs && typedoc --options typedoc.json src/",
19
+ "format": "prettier --write \"src/**/*.ts\"",
20
+ "lint": "eslint -c .eslintrc.cjs --ext .ts src --fix",
21
+ "preversion": "npm run lint",
22
+ "version": "npm run format && git add -A src"
23
+
24
+ },
25
+ "files": [
26
+ "lib/**/*"
27
+ ],
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/spinajs/validation.git"
31
+ },
32
+ "keywords": [
33
+ "spinajs",
34
+ "validation",
35
+ "schema"
36
+ ],
37
+ "author": "SpinaJS <spinajs@coderush.pl> (https://github.com/spinajs/core)",
38
+ "license": "MIT",
39
+ "bugs": {
40
+ "url": "https://github.com/spinajs/validation/issues"
41
+ },
42
+ "homepage": "https://github.com/spinajs/validation#readme",
43
+ "dependencies": {
44
+ "@spinajs/configuration": "^2.0.46",
45
+ "@spinajs/di": "^2.0.46",
46
+ "@spinajs/exceptions": "^2.0.39",
47
+ "@spinajs/log": "^2.0.46",
48
+ "ajv": "^8.12.0",
49
+ "ajv-formats": "^2.1.1",
50
+ "ajv-keywords": "^5.1.0",
51
+ "ajv-merge-patch": "^5.0.1",
52
+ "lodash": "^4.17.21"
53
+ },
54
+ "gitHead": "002dc553b0ffffd72193d0121ac425a4083bc9ee"
55
+ }