@spinajs/validation 2.0.180 → 2.0.182

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.
Files changed (45) hide show
  1. package/lib/cjs/bootstrap.d.ts +4 -4
  2. package/lib/cjs/bootstrap.js +23 -23
  3. package/lib/cjs/bootstrap.js.map +1 -1
  4. package/lib/cjs/config/validation.d.ts +9 -9
  5. package/lib/cjs/config/validation.js +15 -15
  6. package/lib/cjs/decorators.d.ts +8 -8
  7. package/lib/cjs/decorators.js +16 -16
  8. package/lib/cjs/exceptions/index.d.ts +11 -11
  9. package/lib/cjs/exceptions/index.js +14 -14
  10. package/lib/cjs/index.d.ts +13 -13
  11. package/lib/cjs/index.js +34 -34
  12. package/lib/cjs/schemas/validation.d.ts +21 -21
  13. package/lib/cjs/schemas/validation.js +15 -15
  14. package/lib/cjs/sources.d.ts +13 -13
  15. package/lib/cjs/sources.js +92 -93
  16. package/lib/cjs/sources.js.map +1 -1
  17. package/lib/cjs/types.d.ts +17 -17
  18. package/lib/cjs/types.js +6 -6
  19. package/lib/cjs/validator.d.ts +61 -61
  20. package/lib/cjs/validator.js +164 -164
  21. package/lib/cjs/validator.js.map +1 -1
  22. package/lib/mjs/bootstrap.d.ts +4 -4
  23. package/lib/mjs/bootstrap.js +17 -17
  24. package/lib/mjs/bootstrap.js.map +1 -1
  25. package/lib/mjs/config/validation.d.ts +9 -9
  26. package/lib/mjs/config/validation.js +13 -13
  27. package/lib/mjs/decorators.d.ts +8 -8
  28. package/lib/mjs/decorators.js +12 -12
  29. package/lib/mjs/exceptions/index.d.ts +11 -11
  30. package/lib/mjs/exceptions/index.js +10 -10
  31. package/lib/mjs/index.d.ts +13 -13
  32. package/lib/mjs/index.js +13 -13
  33. package/lib/mjs/schemas/validation.d.ts +21 -21
  34. package/lib/mjs/schemas/validation.js +13 -13
  35. package/lib/mjs/sources.d.ts +13 -13
  36. package/lib/mjs/sources.js +63 -63
  37. package/lib/mjs/sources.js.map +1 -1
  38. package/lib/mjs/types.d.ts +17 -17
  39. package/lib/mjs/types.js +2 -2
  40. package/lib/mjs/validator.d.ts +61 -61
  41. package/lib/mjs/validator.js +158 -158
  42. package/lib/mjs/validator.js.map +1 -1
  43. package/lib/tsconfig.cjs.tsbuildinfo +1 -1
  44. package/lib/tsconfig.mjs.tsbuildinfo +1 -1
  45. package/package.json +5 -5
@@ -1,13 +1,13 @@
1
- export const SCHEMA_SYMBOL = Symbol('SCHEMA_SYMBOL');
2
- /**
3
- *
4
- * Add schema for object eg. model or dto.
5
- *
6
- * @param schema - schema for object or schema name
7
- */
8
- export function Schema(schema) {
9
- return (target) => {
10
- Reflect.defineMetadata(SCHEMA_SYMBOL, schema, target.prototype ?? target);
11
- };
12
- }
1
+ export const SCHEMA_SYMBOL = Symbol('SCHEMA_SYMBOL');
2
+ /**
3
+ *
4
+ * Add schema for object eg. model or dto.
5
+ *
6
+ * @param schema - schema for object or schema name
7
+ */
8
+ export function Schema(schema) {
9
+ return (target) => {
10
+ Reflect.defineMetadata(SCHEMA_SYMBOL, schema, target.prototype ?? target);
11
+ };
12
+ }
13
13
  //# sourceMappingURL=decorators.js.map
@@ -1,12 +1,12 @@
1
- import { Exception } from '@spinajs/exceptions';
2
- import { ErrorObject } from 'ajv';
3
- /**
4
- * The exception that is thrown when JSON entity is checked against schema and is invalid
5
- */
6
- export declare class ValidationFailed extends Exception {
7
- parameter: any;
8
- constructor(message: string, validationErrors: IValidationError[]);
9
- }
10
- export interface IValidationError extends ErrorObject {
11
- }
1
+ import { Exception } from '@spinajs/exceptions';
2
+ import { ErrorObject } from 'ajv';
3
+ /**
4
+ * The exception that is thrown when JSON entity is checked against schema and is invalid
5
+ */
6
+ export declare class ValidationFailed extends Exception {
7
+ parameter: any;
8
+ constructor(message: string, validationErrors: IValidationError[]);
9
+ }
10
+ export interface IValidationError extends ErrorObject {
11
+ }
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1,11 +1,11 @@
1
- import { Exception } from '@spinajs/exceptions';
2
- /**
3
- * The exception that is thrown when JSON entity is checked against schema and is invalid
4
- */
5
- export class ValidationFailed extends Exception {
6
- constructor(message, validationErrors) {
7
- super(message);
8
- this.parameter = validationErrors;
9
- }
10
- }
1
+ import { Exception } from '@spinajs/exceptions';
2
+ /**
3
+ * The exception that is thrown when JSON entity is checked against schema and is invalid
4
+ */
5
+ export class ValidationFailed extends Exception {
6
+ constructor(message, validationErrors) {
7
+ super(message);
8
+ this.parameter = validationErrors;
9
+ }
10
+ }
11
11
  //# sourceMappingURL=index.js.map
@@ -1,14 +1,14 @@
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 { 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';
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 { 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
14
  //# sourceMappingURL=index.d.ts.map
package/lib/mjs/index.js CHANGED
@@ -1,14 +1,14 @@
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 { 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';
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 { 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
14
  //# sourceMappingURL=index.js.map
@@ -1,22 +1,22 @@
1
- declare const CONFIGURATION_SCHEMA: {
2
- $id: string;
3
- $configurationModule: string;
4
- description: string;
5
- type: string;
6
- properties: {
7
- allErrors: {
8
- type: string;
9
- };
10
- removeAdditional: {
11
- type: string;
12
- };
13
- useDefaults: {
14
- type: string;
15
- };
16
- coerceTypes: {
17
- type: string;
18
- };
19
- };
20
- };
21
- export default CONFIGURATION_SCHEMA;
1
+ declare const CONFIGURATION_SCHEMA: {
2
+ $id: string;
3
+ $configurationModule: string;
4
+ description: string;
5
+ type: string;
6
+ properties: {
7
+ allErrors: {
8
+ type: string;
9
+ };
10
+ removeAdditional: {
11
+ type: string;
12
+ };
13
+ useDefaults: {
14
+ type: string;
15
+ };
16
+ coerceTypes: {
17
+ type: string;
18
+ };
19
+ };
20
+ };
21
+ export default CONFIGURATION_SCHEMA;
22
22
  //# sourceMappingURL=validation.d.ts.map
@@ -1,14 +1,14 @@
1
- const CONFIGURATION_SCHEMA = {
2
- $id: 'spinajs/validation.configuration.schema.json',
3
- $configurationModule: 'validation',
4
- description: 'Validation module configuration schema',
5
- type: 'object',
6
- properties: {
7
- allErrors: { type: 'boolean' },
8
- removeAdditional: { type: 'boolean' },
9
- useDefaults: { type: 'boolean' },
10
- coerceTypes: { type: 'boolean' },
11
- },
12
- };
13
- export default CONFIGURATION_SCHEMA;
1
+ const CONFIGURATION_SCHEMA = {
2
+ $id: 'spinajs/validation.configuration.schema.json',
3
+ $configurationModule: 'validation',
4
+ description: 'Validation module configuration schema',
5
+ type: 'object',
6
+ properties: {
7
+ allErrors: { type: 'boolean' },
8
+ removeAdditional: { type: 'boolean' },
9
+ useDefaults: { type: 'boolean' },
10
+ coerceTypes: { type: 'boolean' },
11
+ },
12
+ };
13
+ export default CONFIGURATION_SCHEMA;
14
14
  //# sourceMappingURL=validation.js.map
@@ -1,14 +1,14 @@
1
- import { ISchema, ISchemaObject, SchemaSource } from './types.js';
2
- export declare class FileSystemSource extends SchemaSource {
3
- SchemaDirs: string[];
4
- LoadJSSchema(): Promise<{
5
- schema: ISchemaObject;
6
- file: string;
7
- }[]>;
8
- LoadJSONSchema(): {
9
- schema: ISchemaObject;
10
- file: string;
11
- }[];
12
- Load(): Promise<ISchema[]>;
13
- }
1
+ import { ISchema, ISchemaObject, SchemaSource } from './types.js';
2
+ export declare class FileSystemSource extends SchemaSource {
3
+ SchemaDirs: string[];
4
+ LoadJSSchema(): Promise<{
5
+ schema: ISchemaObject;
6
+ file: string;
7
+ }[]>;
8
+ LoadJSONSchema(): {
9
+ schema: ISchemaObject;
10
+ file: string;
11
+ }[];
12
+ Load(): Promise<ISchema[]>;
13
+ }
14
14
  //# sourceMappingURL=sources.d.ts.map
@@ -1,64 +1,64 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
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: 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() {
39
- if (!this.SchemaDirs)
40
- return [];
41
- return this.SchemaDirs.filter((dir) => fs.existsSync(dir))
42
- .flatMap((d) => glob.sync(path.join(d, '/**/*.+(json)').replace(/\\/g, '/')))
43
- .map((f) => {
44
- return {
45
- schema: JSON.parse(fs.readFileSync(f, 'utf-8')),
46
- file: path.basename(f),
47
- };
48
- });
49
- }
50
- async Load() {
51
- const sJS = await this.LoadJSSchema();
52
- const sJSON = this.LoadJSONSchema();
53
- return sJS.concat(sJSON);
54
- }
55
- };
56
- __decorate([
57
- Config('system.dirs.schemas'),
58
- __metadata("design:type", Array)
59
- ], FileSystemSource.prototype, "SchemaDirs", void 0);
60
- FileSystemSource = __decorate([
61
- Injectable(SchemaSource)
62
- ], FileSystemSource);
63
- export { FileSystemSource };
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
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: 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() {
39
+ if (!this.SchemaDirs)
40
+ return [];
41
+ return this.SchemaDirs.filter((dir) => fs.existsSync(dir))
42
+ .flatMap((d) => glob.sync(path.join(d, '/**/*.+(json)').replace(/\\/g, '/')))
43
+ .map((f) => {
44
+ return {
45
+ schema: JSON.parse(fs.readFileSync(f, 'utf-8')),
46
+ file: path.basename(f),
47
+ };
48
+ });
49
+ }
50
+ async Load() {
51
+ const sJS = await this.LoadJSSchema();
52
+ const sJSON = this.LoadJSONSchema();
53
+ return sJS.concat(sJSON);
54
+ }
55
+ };
56
+ __decorate([
57
+ Config('system.dirs.schemas'),
58
+ __metadata("design:type", Array)
59
+ ], FileSystemSource.prototype, "SchemaDirs", void 0);
60
+ FileSystemSource = __decorate([
61
+ Injectable(SchemaSource)
62
+ ], 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,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,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C,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,CAAkB;gBAChE,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;AA5CQ;IADN,MAAM,CAAC,qBAAqB,CAAC;;oDACF;AAFjB,gBAAgB;IAD5B,UAAU,CAAC,YAAY,CAAC;GACZ,gBAAgB,CA8C5B"}
@@ -1,18 +1,18 @@
1
- export interface ISchema {
2
- schema: ISchemaObject;
3
- file?: string;
4
- }
5
- export interface ISchemaObject {
6
- $id: string;
7
- [key: string]: any;
8
- }
9
- export declare abstract class SchemaSource {
10
- abstract Load(): Promise<ISchema[]>;
11
- }
12
- export interface IValidationOptions {
13
- allErrors: boolean;
14
- removeAdditional: boolean;
15
- useDefaults: boolean;
16
- coerceTypes: boolean;
17
- }
1
+ export interface ISchema {
2
+ schema: ISchemaObject;
3
+ file?: string;
4
+ }
5
+ export interface ISchemaObject {
6
+ $id: string;
7
+ [key: string]: any;
8
+ }
9
+ export declare abstract class SchemaSource {
10
+ abstract Load(): Promise<ISchema[]>;
11
+ }
12
+ export interface IValidationOptions {
13
+ allErrors: boolean;
14
+ removeAdditional: boolean;
15
+ useDefaults: boolean;
16
+ coerceTypes: boolean;
17
+ }
18
18
  //# sourceMappingURL=types.d.ts.map
package/lib/mjs/types.js CHANGED
@@ -1,3 +1,3 @@
1
- export class SchemaSource {
2
- }
1
+ export class SchemaSource {
2
+ }
3
3
  //# sourceMappingURL=types.js.map
@@ -1,62 +1,62 @@
1
- import { Container, AsyncService } from '@spinajs/di';
2
- import { IValidationError } from './exceptions/index.js';
3
- import { IValidationOptions, SchemaSource, ISchemaObject } from './types.js';
4
- import { Log } from '@spinajs/log-common';
5
- import './sources.js';
6
- /**
7
- * HACK:
8
- * Becouse of ajv not supporting esm default exports we need to
9
- * check for default export module property and if not provided use module itself
10
- */
11
- export declare class DataValidator extends AsyncService {
12
- Options: IValidationOptions;
13
- protected Sources: SchemaSource[];
14
- protected Log: Log;
15
- /**
16
- * We ignore this error because ajv have problems with
17
- * commonjs / esm default exports
18
- */
19
- protected Validator: any;
20
- protected Container: Container;
21
- resolve(): Promise<void>;
22
- addSchema(schemaObject: object, identifier: string): void;
23
- /**
24
- *
25
- * Checks if schema is loaded ( from file )
26
- *
27
- * @param schemaId - schema id to check
28
- * @returns true if schema is loaded, false otherwise
29
- */
30
- hasSchema(schemaId: string): boolean;
31
- /**
32
- * Tries to validate given data
33
- *
34
- * @param data - data to validate. Function will try to extract schema attached to object via `@Schema` decorator
35
- *
36
- */
37
- tryValidate(data: object): [boolean, IValidationError[]];
38
- /**
39
- * Tries to validate given data
40
- *
41
- * @param schemaKeyRef - key, ref or schema object
42
- * @param data - to be validated
43
- */
44
- tryValidate(schema: object | string, data: object): [boolean, IValidationError[]];
45
- extractSchema(object: unknown): ISchemaObject;
46
- /**
47
- * Validate given data. When failed, exception is thrown
48
- *s
49
- * @param data - data to validate. Function will try to extract schema attached to object via `@Schema` decorator
50
- * @throws {@link InvalidArgument | ValidationFailed }
51
- */
52
- validate(data: object): void;
53
- /**
54
- * Validate given data
55
- *
56
- * @param schemaKeyRef - key, ref or schema object
57
- * @param data - to be validated
58
- * @throws {@link InvalidArgumen | ValidationFailed }
59
- */
60
- validate(schema: object | string, data: object): void;
61
- }
1
+ import { Container, AsyncService } from '@spinajs/di';
2
+ import { IValidationError } from './exceptions/index.js';
3
+ import { IValidationOptions, SchemaSource, ISchemaObject } from './types.js';
4
+ import { Log } from '@spinajs/log-common';
5
+ import './sources.js';
6
+ /**
7
+ * HACK:
8
+ * Becouse of ajv not supporting esm default exports we need to
9
+ * check for default export module property and if not provided use module itself
10
+ */
11
+ export declare class DataValidator extends AsyncService {
12
+ Options: IValidationOptions;
13
+ protected Sources: SchemaSource[];
14
+ protected Log: Log;
15
+ /**
16
+ * We ignore this error because ajv have problems with
17
+ * commonjs / esm default exports
18
+ */
19
+ protected Validator: any;
20
+ protected Container: Container;
21
+ resolve(): Promise<void>;
22
+ addSchema(schemaObject: object, identifier: string): void;
23
+ /**
24
+ *
25
+ * Checks if schema is loaded ( from file )
26
+ *
27
+ * @param schemaId - schema id to check
28
+ * @returns true if schema is loaded, false otherwise
29
+ */
30
+ hasSchema(schemaId: string): boolean;
31
+ /**
32
+ * Tries to validate given data
33
+ *
34
+ * @param data - data to validate. Function will try to extract schema attached to object via `@Schema` decorator
35
+ *
36
+ */
37
+ tryValidate(data: object): [boolean, IValidationError[]];
38
+ /**
39
+ * Tries to validate given data
40
+ *
41
+ * @param schemaKeyRef - key, ref or schema object
42
+ * @param data - to be validated
43
+ */
44
+ tryValidate(schema: object | string, data: object): [boolean, IValidationError[]];
45
+ extractSchema(object: unknown): ISchemaObject;
46
+ /**
47
+ * Validate given data. When failed, exception is thrown
48
+ *s
49
+ * @param data - data to validate. Function will try to extract schema attached to object via `@Schema` decorator
50
+ * @throws {@link InvalidArgument | ValidationFailed }
51
+ */
52
+ validate(data: object): void;
53
+ /**
54
+ * Validate given data
55
+ *
56
+ * @param schemaKeyRef - key, ref or schema object
57
+ * @param data - to be validated
58
+ * @throws {@link InvalidArgumen | ValidationFailed }
59
+ */
60
+ validate(schema: object | string, data: object): void;
61
+ }
62
62
  //# sourceMappingURL=validator.d.ts.map