@allgemein/schema-api 1.5.30 → 1.5.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser.d.ts +5 -5
- package/browser.js +23 -32
- package/browser.js.map +1 -1
- package/lib/DataContainer.js +1 -1
- package/lib/DataContainer.js.map +1 -1
- package/lib/LookupRegistry.js +6 -6
- package/lib/LookupRegistry.js.map +1 -1
- package/package.json +1 -1
package/browser.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { IBaseRef } from './api/IBaseRef';
|
|
2
2
|
export { IBuildOptions } from './api/IBuildOptions';
|
|
3
|
-
export { IClassRef } from './api/IClassRef';
|
|
4
|
-
export { IEntityRef } from './api/IEntityRef';
|
|
5
|
-
export { ILookupRegistry } from './api/ILookupRegistry';
|
|
3
|
+
export { IClassRef, isClassRef } from './api/IClassRef';
|
|
4
|
+
export { IEntityRef, isEntityRef } from './api/IEntityRef';
|
|
5
|
+
export { ILookupRegistry, isLookupRegistry } from './api/ILookupRegistry';
|
|
6
6
|
export { IPropertyExtentions } from './api/IPropertyExtentions';
|
|
7
|
-
export { IPropertyRef } from './api/IPropertyRef';
|
|
7
|
+
export { IPropertyRef, isPropertyRef } from './api/IPropertyRef';
|
|
8
8
|
export { ISchemaRef } from './api/ISchemaRef';
|
|
9
9
|
export { IJsonSchema, supportsJsonSchemaExport, supportsJsonSchema, supportsJsonSchemaImport } from './api/IJsonSchema';
|
|
10
10
|
export { Entity } from './decorators/Entity';
|
|
@@ -26,7 +26,7 @@ export { AbstractRef } from './lib/AbstractRef';
|
|
|
26
26
|
export { AbstractRegistry } from './lib/registry/AbstractRegistry';
|
|
27
27
|
export { AnnotationsHelper } from './lib/AnnotationsHelper';
|
|
28
28
|
export { ClassRef } from './lib/ClassRef';
|
|
29
|
-
export
|
|
29
|
+
export * from './lib/Constants';
|
|
30
30
|
export { DataContainer } from './lib/DataContainer';
|
|
31
31
|
export { DRAFT_07 } from './lib/json-schema/Constants';
|
|
32
32
|
export { IJsonSchemaSerializeOptions } from './lib/json-schema/IJsonSchemaSerializeOptions';
|
package/browser.js
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
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 __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);
|
|
11
|
+
};
|
|
2
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.getClassName =
|
|
13
|
+
exports.Validator = exports.DefaultValidator = exports.SchemaUtils = exports.SchemaRef = exports.Binding = exports.RegistryFactory = exports.MetadataRegistry = exports.DefaultPropertyRef = exports.DefaultNamespacedRegistry = exports.DefaultEntityRef = exports.LookupRegistry = exports.JsonSchema7Unserializer = exports.JsonSchema7Serializer = exports.JSON_SCHEMA_7_TYPES = exports.hasClassPropertiesInDefinition = exports.hasClassInDefinition = exports.JsonSchema = exports.DRAFT_07 = exports.DataContainer = exports.ClassRef = exports.AnnotationsHelper = exports.AbstractRegistry = exports.AbstractRef = exports.IsNotEmpty = exports.MaxLength = exports.MinLength = exports.Required = exports.Regex = exports.MAIL_REGEX = exports.IsEmail = exports.IP6_REGEX = exports.Ip6 = exports.IP4_REGEX = exports.Ip4 = exports.HOSTNAME_RFC952_REGEX = exports.HOSTNAME_RFC1034_REGEX = exports.Hostname = exports.Namespace = exports.Schema = exports.PropertyOf = exports.Embeddable = exports.Property = exports.Entity = exports.supportsJsonSchemaImport = exports.supportsJsonSchema = exports.supportsJsonSchemaExport = exports.isPropertyRef = exports.isLookupRegistry = exports.isEntityRef = exports.isClassRef = void 0;
|
|
14
|
+
exports.getClassName = void 0;
|
|
15
|
+
var IClassRef_1 = require("./api/IClassRef");
|
|
16
|
+
Object.defineProperty(exports, "isClassRef", { enumerable: true, get: function () { return IClassRef_1.isClassRef; } });
|
|
17
|
+
var IEntityRef_1 = require("./api/IEntityRef");
|
|
18
|
+
Object.defineProperty(exports, "isEntityRef", { enumerable: true, get: function () { return IEntityRef_1.isEntityRef; } });
|
|
19
|
+
var ILookupRegistry_1 = require("./api/ILookupRegistry");
|
|
20
|
+
Object.defineProperty(exports, "isLookupRegistry", { enumerable: true, get: function () { return ILookupRegistry_1.isLookupRegistry; } });
|
|
21
|
+
var IPropertyRef_1 = require("./api/IPropertyRef");
|
|
22
|
+
Object.defineProperty(exports, "isPropertyRef", { enumerable: true, get: function () { return IPropertyRef_1.isPropertyRef; } });
|
|
5
23
|
var IJsonSchema_1 = require("./api/IJsonSchema");
|
|
6
24
|
Object.defineProperty(exports, "supportsJsonSchemaExport", { enumerable: true, get: function () { return IJsonSchema_1.supportsJsonSchemaExport; } });
|
|
7
25
|
Object.defineProperty(exports, "supportsJsonSchema", { enumerable: true, get: function () { return IJsonSchema_1.supportsJsonSchema; } });
|
|
@@ -49,38 +67,11 @@ var AnnotationsHelper_1 = require("./lib/AnnotationsHelper");
|
|
|
49
67
|
Object.defineProperty(exports, "AnnotationsHelper", { enumerable: true, get: function () { return AnnotationsHelper_1.AnnotationsHelper; } });
|
|
50
68
|
var ClassRef_1 = require("./lib/ClassRef");
|
|
51
69
|
Object.defineProperty(exports, "ClassRef", { enumerable: true, get: function () { return ClassRef_1.ClassRef; } });
|
|
52
|
-
|
|
53
|
-
Object.defineProperty(exports, "METATYPE_SCHEMA", { enumerable: true, get: function () { return Constants_1.METATYPE_SCHEMA; } });
|
|
54
|
-
Object.defineProperty(exports, "METATYPE_ENTITY", { enumerable: true, get: function () { return Constants_1.METATYPE_ENTITY; } });
|
|
55
|
-
Object.defineProperty(exports, "METATYPE_PROPERTY", { enumerable: true, get: function () { return Constants_1.METATYPE_PROPERTY; } });
|
|
56
|
-
Object.defineProperty(exports, "METATYPE_CLASS_REF", { enumerable: true, get: function () { return Constants_1.METATYPE_CLASS_REF; } });
|
|
57
|
-
Object.defineProperty(exports, "METATYPE_NAMESPACE", { enumerable: true, get: function () { return Constants_1.METATYPE_NAMESPACE; } });
|
|
58
|
-
Object.defineProperty(exports, "DEFAULT_NAMESPACE", { enumerable: true, get: function () { return Constants_1.DEFAULT_NAMESPACE; } });
|
|
59
|
-
Object.defineProperty(exports, "XS_ANNOTATION_OPTIONS_CACHE", { enumerable: true, get: function () { return Constants_1.XS_ANNOTATION_OPTIONS_CACHE; } });
|
|
60
|
-
Object.defineProperty(exports, "__CLASS__", { enumerable: true, get: function () { return Constants_1.__CLASS__; } });
|
|
61
|
-
Object.defineProperty(exports, "__NS__", { enumerable: true, get: function () { return Constants_1.__NS__; } });
|
|
62
|
-
Object.defineProperty(exports, "C_EVENT_ADD", { enumerable: true, get: function () { return Constants_1.C_EVENT_ADD; } });
|
|
63
|
-
Object.defineProperty(exports, "C_EVENT_REMOVE", { enumerable: true, get: function () { return Constants_1.C_EVENT_REMOVE; } });
|
|
64
|
-
Object.defineProperty(exports, "C_EVENT_UPDATE", { enumerable: true, get: function () { return Constants_1.C_EVENT_UPDATE; } });
|
|
65
|
-
Object.defineProperty(exports, "C_PROP_NAME", { enumerable: true, get: function () { return Constants_1.C_PROP_NAME; } });
|
|
66
|
-
Object.defineProperty(exports, "GLOBAL_NAMESPACE", { enumerable: true, get: function () { return Constants_1.GLOBAL_NAMESPACE; } });
|
|
67
|
-
Object.defineProperty(exports, "JS_DATA_TYPES", { enumerable: true, get: function () { return Constants_1.JS_DATA_TYPES; } });
|
|
68
|
-
Object.defineProperty(exports, "JS_PRIMATIVE_TYPES", { enumerable: true, get: function () { return Constants_1.JS_PRIMATIVE_TYPES; } });
|
|
69
|
-
Object.defineProperty(exports, "METADATA_REGISTRY", { enumerable: true, get: function () { return Constants_1.METADATA_REGISTRY; } });
|
|
70
|
-
Object.defineProperty(exports, "METATYPE_EMBEDDABLE", { enumerable: true, get: function () { return Constants_1.METATYPE_EMBEDDABLE; } });
|
|
71
|
-
Object.defineProperty(exports, "OPT_CREAT_AND_COPY", { enumerable: true, get: function () { return Constants_1.OPT_CREAT_AND_COPY; } });
|
|
72
|
-
Object.defineProperty(exports, "REFLECT_DESIGN_TYPE", { enumerable: true, get: function () { return Constants_1.REFLECT_DESIGN_TYPE; } });
|
|
73
|
-
Object.defineProperty(exports, "STATE_KEY", { enumerable: true, get: function () { return Constants_1.STATE_KEY; } });
|
|
74
|
-
Object.defineProperty(exports, "T_STRING", { enumerable: true, get: function () { return Constants_1.T_STRING; } });
|
|
75
|
-
Object.defineProperty(exports, "XS_DEFAULT_CLASSES", { enumerable: true, get: function () { return Constants_1.XS_DEFAULT_CLASSES; } });
|
|
76
|
-
Object.defineProperty(exports, "XS_DEFAULT_SCHEMA", { enumerable: true, get: function () { return Constants_1.XS_DEFAULT_SCHEMA; } });
|
|
77
|
-
Object.defineProperty(exports, "XS_ID_SEPARATOR", { enumerable: true, get: function () { return Constants_1.XS_ID_SEPARATOR; } });
|
|
78
|
-
Object.defineProperty(exports, "BINDING_SCHEMA_ENTITY", { enumerable: true, get: function () { return Constants_1.BINDING_SCHEMA_ENTITY; } });
|
|
79
|
-
Object.defineProperty(exports, "BINDING_SCHEMA_CLASS_REF", { enumerable: true, get: function () { return Constants_1.BINDING_SCHEMA_CLASS_REF; } });
|
|
70
|
+
__exportStar(require("./lib/Constants"), exports);
|
|
80
71
|
var DataContainer_1 = require("./lib/DataContainer");
|
|
81
72
|
Object.defineProperty(exports, "DataContainer", { enumerable: true, get: function () { return DataContainer_1.DataContainer; } });
|
|
82
|
-
var
|
|
83
|
-
Object.defineProperty(exports, "DRAFT_07", { enumerable: true, get: function () { return
|
|
73
|
+
var Constants_1 = require("./lib/json-schema/Constants");
|
|
74
|
+
Object.defineProperty(exports, "DRAFT_07", { enumerable: true, get: function () { return Constants_1.DRAFT_07; } });
|
|
84
75
|
var JsonSchema_1 = require("./lib/json-schema/JsonSchema");
|
|
85
76
|
Object.defineProperty(exports, "JsonSchema", { enumerable: true, get: function () { return JsonSchema_1.JsonSchema; } });
|
|
86
77
|
var JsonSchema7_1 = require("./lib/json-schema/JsonSchema7");
|
package/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/browser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,6CAAsD;AAAnC,uGAAA,UAAU,OAAA;AAC7B,+CAAyD;AAArC,yGAAA,WAAW,OAAA;AAC/B,yDAAwE;AAA/C,mHAAA,gBAAgB,OAAA;AAEzC,mDAA+D;AAAzC,6GAAA,aAAa,OAAA;AAEnC,iDAK2B;AAHzB,uHAAA,wBAAwB,OAAA;AACxB,iHAAA,kBAAkB,OAAA;AAClB,uHAAA,wBAAwB,OAAA;AAG1B,8CAA2C;AAAnC,gGAAA,MAAM,OAAA;AACd,kDAA+C;AAAvC,oGAAA,QAAQ,OAAA;AAChB,sDAAmD;AAA3C,wGAAA,UAAU,OAAA;AAClB,sDAAmD;AAA3C,wGAAA,UAAU,OAAA;AAClB,8CAA2C;AAAnC,gGAAA,MAAM,OAAA;AACd,oDAAiD;AAAzC,sGAAA,SAAS,OAAA;AAEjB,2DAKwC;AAJtC,oGAAA,QAAQ,OAAA;AACR,kHAAA,sBAAsB,OAAA;AAEtB,iHAAA,qBAAqB,OAAA;AAGvB,iDAAsE;AAA9D,0FAAA,GAAG,OAAA;AAAE,gGAAA,SAAS,OAAA;AACtB,iDAAsE;AAA9D,0FAAA,GAAG,OAAA;AAAE,gGAAA,SAAS,OAAA;AACtB,yDAAmF;AAA3E,kGAAA,OAAO,OAAA;A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":"browser.js","sourcesContent":["export {IBaseRef} from './api/IBaseRef';\nexport {IBuildOptions} from './api/IBuildOptions';\nexport {IClassRef, isClassRef} from './api/IClassRef';\nexport {IEntityRef, isEntityRef} from './api/IEntityRef';\nexport {ILookupRegistry, isLookupRegistry} from './api/ILookupRegistry';\nexport {IPropertyExtentions} from './api/IPropertyExtentions';\nexport {IPropertyRef, isPropertyRef} from './api/IPropertyRef';\nexport {ISchemaRef} from './api/ISchemaRef';\nexport {\n IJsonSchema,\n supportsJsonSchemaExport,\n supportsJsonSchema,\n supportsJsonSchemaImport\n} from './api/IJsonSchema';\n\nexport {Entity} from './decorators/Entity';\nexport {Property} from './decorators/Property';\nexport {Embeddable} from './decorators/Embeddable';\nexport {PropertyOf} from './decorators/PropertyOf';\nexport {Schema} from './decorators/Schema';\nexport {Namespace} from './decorators/Namespace';\n\nexport {\n Hostname,\n HOSTNAME_RFC1034_REGEX,\n IHostnameOptions,\n HOSTNAME_RFC952_REGEX\n} from './decorators/validate/Hostname';\n\nexport {Ip4, IP4_REGEX, IIp4Options} from './decorators/validate/Ip4';\nexport {Ip6, IP6_REGEX, IIp6Options} from './decorators/validate/Ip6';\nexport {IsEmail, MAIL_REGEX, IIsEmailOptions} from './decorators/validate/IsEmail';\nexport {Regex, IRegexOptions} from './decorators/validate/Regex';\nexport {Required, IRequiredOptions} from './decorators/validate/Required';\nexport {MinLength, IMinLengthOptions} from './decorators/validate/MinLength';\nexport {MaxLength, IMaxLengthOptions} from './decorators/validate/MaxLength';\nexport {IsNotEmpty, IIsNotEmptyOptions} from './decorators/validate/IsNotEmpty';\n\nexport {AbstractRef} from './lib/AbstractRef';\nexport {AbstractRegistry} from './lib/registry/AbstractRegistry';\n\nexport {AnnotationsHelper} from './lib/AnnotationsHelper';\nexport {ClassRef} from './lib/ClassRef';\nexport * from './lib/Constants';\n\nexport {DataContainer} from './lib/DataContainer';\nexport {DRAFT_07} from './lib/json-schema/Constants';\nexport {IJsonSchemaSerializeOptions} from './lib/json-schema/IJsonSchemaSerializeOptions';\nexport {IJsonSchemaSerializer} from './lib/json-schema/IJsonSchemaSerializer';\nexport {IJsonSchemaUnserializeOptions} from './lib/json-schema/IJsonSchemaUnserializeOptions';\nexport {IJsonSchemaUnserializer} from './lib/json-schema/IJsonSchemaUnserializer';\nexport {IParseOptions} from './lib/json-schema/IParseOptions';\nexport {JsonSchema} from './lib/json-schema/JsonSchema';\n\nexport {\n IJsonSchema7,\n IJsonSchema7Definition,\n hasClassInDefinition,\n hasClassPropertiesInDefinition,\n IJsonSchema7TypeName,\n JSON_SCHEMA_7_TYPES\n} from './lib/json-schema/JsonSchema7';\n\nexport {JsonSchema7Serializer} from './lib/json-schema/JsonSchema7Serializer';\nexport {JsonSchema7Unserializer} from './lib/json-schema/JsonSchema7Unserializer';\nexport {LookupRegistry} from './lib/LookupRegistry';\nexport {INamedOptions} from './lib/options/INamedOptions';\nexport {IAbstractOptions} from './lib/options/IAbstractOptions';\nexport {IAttributeOptions} from './lib/options/IAttributeOptions';\nexport {IEntityOptions} from './lib/options/IEntityOptions';\nexport {IObjectOptions} from './lib/options/IObjectOptions';\nexport {IPropertyOptions} from './lib/options/IPropertyOptions';\nexport {ISchemaOptions} from './lib/options/ISchemaOptions';\n\nexport {DefaultEntityRef} from './lib/registry/DefaultEntityRef';\nexport {DefaultNamespacedRegistry} from './lib/registry/DefaultNamespacedRegistry';\nexport {DefaultPropertyRef} from './lib/registry/DefaultPropertyRef';\nexport {MetadataRegistry} from './lib/registry/MetadataRegistry';\nexport {RegistryFactory} from './lib/registry/RegistryFactory';\nexport {Binding} from './lib/registry/Binding';\nexport {SchemaRef} from './lib/SchemaRef';\nexport {SchemaUtils} from './lib/SchemaUtils';\nexport {DefaultValidator} from './lib/validation/DefaultValidator';\nexport {IValidateOptions} from './lib/validation/IValidateOptions';\nexport {IValidatorEntry} from './lib/validation/IValidatorEntry';\nexport {IValidationError} from './lib/validation/IValidationError';\nexport {IValidationMessage} from './lib/validation/IValidationMessage';\nexport {IValidationResult} from './lib/validation/IValidationResult';\nexport {IValidator} from './lib/validation/IValidator';\nexport {Validator, validate_function} from './lib/validation/Validator';\nexport {getClassName} from './lib/functions';\n"],"sourceRoot":"."}
|
package/lib/DataContainer.js
CHANGED
|
@@ -105,7 +105,7 @@ class DataContainer {
|
|
|
105
105
|
(0, lodash_1.keys)(this.validation).forEach(key => {
|
|
106
106
|
if (this.validation[key]) {
|
|
107
107
|
const valid = this.validation[key];
|
|
108
|
-
const found =
|
|
108
|
+
const found = this.errors.find(x => x.property === key);
|
|
109
109
|
valid.messages = [];
|
|
110
110
|
if (found) {
|
|
111
111
|
valid.valid = false;
|
package/lib/DataContainer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/DataContainer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/DataContainer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAAmF;AAGnF,2CAAsC;AAOtC,sDAAiD;AACjD,yCAAoC;AACpC,0CAA2C;AAE3C;;GAEG;AACH,MAAa,aAAa;IAwBxB,YAAY,QAAW,EAAE,QAAmD;QAT5E,WAAM,GAAuB,EAAE,CAAC;QAEhC,eAAU,GAAuC,EAAE,CAAC;QAQlD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,QAAQ,EAAE;YACZ,IAAI,CAAC,GAAG,GAAG,IAAA,mBAAU,EAAmB,QAAS,CAAC,eAAe,CAAC,CAAC,CAAC;gBAChD,QAAS,CAAC,eAAe,CAAC,QAAe,CAAC,CAAC,CAAC,CAAC,QAAsB,CAAC;SACzF;aAAM;YACL,MAAM,KAAK,GAAG,iBAAU,CAAC,WAAW,CAAC,QAAe,CAAC,CAAC;YACtD,IAAI,CAAC,GAAG,GAAG,mBAAQ,CAAC,GAAG,CAAC,KAAK,CAAc,CAAC;SAC7C;QACD,IAAI,CAAC,IAAI,CAAC,GA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EAAC,KAAK,CAAC,EAAE;gBACvC,IAAA,YAAG,EAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;aACvB;QACH,CAAC,CAAC,CAAC;QAEH,IAAA,YAAG,EAAM,IAAI,CAAC,QAAQ,EAAE,qBAAS,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;IAGD,WAAW;QACT,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;;AA7JH,sCA8JC;AA5JQ,kBAAI,GAAa;IACtB,aAAa;IACb,WAAW;IACX,oBAAoB;IACpB,QAAQ;CACT,CAAC","file":"DataContainer.js","sourcesContent":["import {get, has, isBoolean, isEmpty, isFunction, keys, remove, set} from 'lodash';\n\n\nimport {STATE_KEY} from './Constants';\nimport {IValidationError} from './validation/IValidationError';\nimport {IValidationResult} from './validation/IValidationResult';\nimport {ILookupRegistry} from '../api/ILookupRegistry';\nimport {IEntityRef} from '../api/IEntityRef';\nimport {IClassRef} from '../api/IClassRef';\nimport {IValidationMessage} from './validation/IValidationMessage';\nimport {Validator} from './validation/Validator';\nimport {ClassRef} from './ClassRef';\nimport {ClassUtils} from '@allgemein/base';\n\n/**\n * Container for validation of object\n */\nexport class DataContainer<T> {\n\n static keys: string[] = [\n 'isValidated',\n 'isSuccess',\n 'isSuccessValidated',\n 'errors'\n ];\n\n isValidated: boolean;\n\n isSuccess: boolean;\n\n isSuccessValidated: boolean;\n\n errors: IValidationError[] = [];\n\n validation: { [k: string]: IValidationResult } = {};\n\n instance: T;\n\n ref: IEntityRef | IClassRef;\n\n\n constructor(instance: T, registry?: ILookupRegistry | IEntityRef | IClassRef) {\n this.instance = instance;\n if (registry) {\n this.ref = isFunction((<ILookupRegistry>registry).getEntityRefFor) ?\n (<ILookupRegistry>registry).getEntityRefFor(instance as any) : registry as IEntityRef;\n } else {\n const clazz = ClassUtils.getFunction(instance as any);\n this.ref = ClassRef.get(clazz) as IClassRef;\n }\n if (!this.ref) {\n throw new Error('none definition found for instance ' + JSON.stringify(instance));\n }\n\n const properties = this.ref.getPropertyRefs();\n for (const property of properties) {\n this.validation[property.name] = {\n key: property.name,\n valid: false,\n checked: false,\n messages: []\n };\n }\n ;\n }\n\n\n addError(e: IValidationError) {\n if (!has(e, 'type')) {\n e.type = 'error';\n }\n this.errors.push(e);\n }\n\n\n hasErrors() {\n return this.errors.length > 0;\n }\n\n\n checked(str: string) {\n if (this.validation[str]) {\n return this.validation[str].checked;\n }\n return false;\n }\n\n\n value(str: string) {\n const wrap = {};\n Object.defineProperty(wrap, str, {\n get: () => {\n return this.instance[str];\n },\n set: (y: any) => {\n this.instance[str] = y;\n }\n });\n return wrap[str];\n }\n\n\n valid(str: string) {\n if (this.validation[str]) {\n return this.validation[str].valid;\n }\n return false;\n }\n\n\n messages(str: string): IValidationMessage[] {\n if (this.validation[str] && this.validation[str].messages) {\n return this.validation[str].messages;\n }\n return [];\n\n }\n\n\n async validate(): Promise<boolean> {\n this.isValidated = true;\n remove(this.errors, error => error.type === 'validate');\n let results: IValidationError[] = [];\n try {\n results = <IValidationError[]>await Validator.validate(this.instance as any, this.ref);\n } catch (e) {\n console.error(e);\n }\n\n results.map(r => this.errors.push({\n property: r.property,\n value: r.value,\n constraints: r.constraints,\n type: 'validate'\n }));\n this.isSuccessValidated = true;\n keys(this.validation).forEach(key => {\n if (this.validation[key]) {\n const valid = this.validation[key];\n const found = this.errors.find(x => x.property === key);\n valid.messages = [];\n if (found) {\n valid.valid = false;\n Object.keys(found.constraints).forEach(c => {\n valid.messages.push({type: c, content: found.constraints[c]});\n });\n } else {\n valid.valid = true;\n }\n this.isSuccessValidated = this.isSuccessValidated && valid.valid;\n valid.checked = true;\n }\n });\n\n return this.isSuccessValidated;\n }\n\n\n applyState() {\n const $state: any = {};\n DataContainer.keys.forEach(k => {\n const value = get(this, k, null);\n\n if (isBoolean(value) || !isEmpty(value)) {\n set($state, k, value);\n }\n });\n\n set(<any>this.instance, STATE_KEY, $state);\n }\n\n\n resetErrors() {\n this.errors = [];\n }\n}\n"],"sourceRoot":".."}
|
package/lib/LookupRegistry.js
CHANGED
|
@@ -46,25 +46,25 @@ class LookupRegistry {
|
|
|
46
46
|
if (!(0, lodash_1.has)(this._entries, context)) {
|
|
47
47
|
this._entries[context] = [];
|
|
48
48
|
}
|
|
49
|
-
return
|
|
49
|
+
return this._entries[context].filter(search);
|
|
50
50
|
}
|
|
51
51
|
find(context, search) {
|
|
52
52
|
if (!(0, lodash_1.has)(this._entries, context)) {
|
|
53
53
|
this._entries[context] = [];
|
|
54
54
|
}
|
|
55
|
-
return
|
|
55
|
+
return this._entries[context].find(search);
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
58
|
* return lookup registry namespaces
|
|
59
59
|
*/
|
|
60
60
|
static getRegistryNamespaces() {
|
|
61
|
-
return
|
|
61
|
+
return Object.keys(this.$self);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* return lookup registries
|
|
65
65
|
*/
|
|
66
66
|
static getLookupRegistries() {
|
|
67
|
-
return
|
|
67
|
+
return Object.keys(this.$self).map(x => this.$self[x]);
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* search in all registries
|
|
@@ -73,7 +73,7 @@ class LookupRegistry {
|
|
|
73
73
|
* @param search
|
|
74
74
|
*/
|
|
75
75
|
static find(context, search) {
|
|
76
|
-
const registryNames =
|
|
76
|
+
const registryNames = this.getRegistryNamespaces();
|
|
77
77
|
for (const registryName of registryNames) {
|
|
78
78
|
const found = this.$self[registryName].find(context, search);
|
|
79
79
|
if (found) {
|
|
@@ -90,7 +90,7 @@ class LookupRegistry {
|
|
|
90
90
|
*/
|
|
91
91
|
static filter(context, search) {
|
|
92
92
|
const results = [];
|
|
93
|
-
const namespaces =
|
|
93
|
+
const namespaces = Object.keys(this.$self);
|
|
94
94
|
for (const namespace of namespaces) {
|
|
95
95
|
const found = this.$self[namespace].filter(context, search);
|
|
96
96
|
if (!(0, lodash_1.isEmpty)(found)) {
|
|
@@ -1 +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CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAI,OAAe,EAAE,MAAW;QACzC,MAAM,aAAa,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACnD,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE;YACxC,MAAM,KAAK,GAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAChE,IAAI,KAAK,EAAE;gBACT,OAAO,KAAK,CAAC;aACd;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAI,OAAe,EAAE,MAAW;QAC3C,MAAM,OAAO,GAAQ,EAAE,CAAC;QACxB,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,MAAM,KAAK,GAAQ,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YACjE,IAAI,CAAC,IAAA,gBAAO,EAAC,KAAK,CAAC,EAAE;gBACnB,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;aACxB;SACF;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;;AAjHH,wCAoHC;AAlHgB,oBAAK,GAA4C,EAAE,CAAC","file":"LookupRegistry.js","sourcesContent":["import {has, isEmpty, remove} from 'lodash';\n\nimport {DEFAULT_NAMESPACE} from './Constants';\n\nexport class LookupRegistry {\n\n private static $self: { [namespace: string]: LookupRegistry } = {};\n\n private namespace: string = DEFAULT_NAMESPACE;\n\n private _entries: { [context: string]: any[] } = {};\n\n constructor(namespace: string) {\n this.namespace = namespace;\n }\n\n getNamespace(): string {\n return this.namespace;\n }\n\n static reset(namespace: string = DEFAULT_NAMESPACE): void {\n if (this.$self[namespace]) {\n delete this.$self[namespace];\n }\n }\n\n static $(namespace: string = DEFAULT_NAMESPACE): LookupRegistry {\n if (!this.$self[namespace]) {\n this.$self[namespace] = new LookupRegistry(namespace);\n }\n return this.$self[namespace];\n }\n\n list(context: string) {\n if (!has(this._entries, context)) {\n this._entries[context] = [];\n }\n return this._entries[context];\n }\n\n add<T>(context: string, entry: T): T {\n if (!has(this._entries, context)) {\n this._entries[context] = [];\n }\n this._entries[context].push(entry);\n return entry;\n }\n\n remove<T>(context: string, search: any): T[] {\n if (!has(this._entries, context)) {\n this._entries[context] = [];\n }\n return remove<T>(this._entries[context], search);\n }\n\n filter<T>(context: string, search: any): T[] {\n if (!has(this._entries, context)) {\n this._entries[context] = [];\n }\n return this._entries[context].filter(search);\n }\n\n find<T>(context: string, search: any): T {\n if (!has(this._entries, context)) {\n this._entries[context] = [];\n }\n return this._entries[context].find(search);\n }\n\n\n /**\n * return lookup registry namespaces\n */\n static getRegistryNamespaces() {\n return Object.keys(this.$self);\n }\n\n /**\n * return lookup registries\n */\n static getLookupRegistries() {\n return Object.keys(this.$self).map(x => this.$self[x]);\n }\n\n /**\n * search in all registries\n *\n * @param context\n * @param search\n */\n static find<T>(context: string, search: any): T {\n const registryNames = this.getRegistryNamespaces();\n for (const registryName of registryNames) {\n const found = <T>this.$self[registryName].find(context, search);\n if (found) {\n return found;\n }\n }\n return null;\n }\n\n /**\n * filter over all registries\n *\n * @param context\n * @param search\n */\n static filter<T>(context: string, search: any): T[] {\n const results: T[] = [];\n const namespaces = Object.keys(this.$self);\n for (const namespace of namespaces) {\n const found = <T[]>this.$self[namespace].filter(context, search);\n if (!isEmpty(found)) {\n results.push(...found);\n }\n }\n return results;\n }\n\n\n}\n\n\n"],"sourceRoot":".."}
|