@leyyo/common 1.0.5 → 1.0.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.
- package/dist/assertion/common-assertion.d.ts +24 -35
- package/dist/assertion/common-assertion.js +73 -142
- package/dist/assertion/common-assertion.js.map +1 -1
- package/dist/assertion/index-types.d.ts +104 -109
- package/dist/assertion/index.d.ts +0 -1
- package/dist/assertion/index.js +0 -1
- package/dist/assertion/index.js.map +1 -1
- package/dist/descriptor/common-descriptor.d.ts +19 -0
- package/dist/descriptor/common-descriptor.js +92 -0
- package/dist/descriptor/common-descriptor.js.map +1 -0
- package/dist/descriptor/index-types.d.ts +21 -0
- package/dist/descriptor/index-types.js.map +1 -0
- package/dist/descriptor/index.d.ts +1 -0
- package/dist/{storage → descriptor}/index.js +0 -1
- package/dist/descriptor/index.js.map +1 -0
- package/dist/developer/common-developer.d.ts +29 -0
- package/dist/developer/common-developer.js +266 -0
- package/dist/developer/common-developer.js.map +1 -0
- package/dist/developer/index-types.d.ts +77 -0
- package/dist/developer/index-types.js.map +1 -0
- package/dist/developer/index.d.ts +1 -0
- package/dist/{literal → developer}/index.js +0 -15
- package/dist/developer/index.js.map +1 -0
- package/dist/error/common-error.js +27 -16
- package/dist/error/common-error.js.map +1 -1
- package/dist/error/index-types.d.ts +19 -0
- package/dist/error/index.d.ts +0 -1
- package/dist/error/index.js +0 -1
- package/dist/error/index.js.map +1 -1
- package/dist/exception/assertion-exception.d.ts +2 -2
- package/dist/exception/assertion-exception.js +2 -2
- package/dist/exception/assertion-exception.js.map +1 -1
- package/dist/exception/caused-exception.d.ts +2 -2
- package/dist/exception/caused-exception.js +2 -2
- package/dist/exception/caused-exception.js.map +1 -1
- package/dist/exception/developer-exception.d.ts +2 -2
- package/dist/exception/developer-exception.js +2 -2
- package/dist/exception/developer-exception.js.map +1 -1
- package/dist/exception/exception.d.ts +3 -1
- package/dist/exception/exception.js +13 -4
- package/dist/exception/exception.js.map +1 -1
- package/dist/exception/index-types.d.ts +1 -1
- package/dist/exception/index.d.ts +1 -0
- package/dist/exception/index.js +1 -0
- package/dist/exception/index.js.map +1 -1
- package/dist/exception/invalid-value-exception.d.ts +5 -0
- package/dist/exception/invalid-value-exception.js +12 -0
- package/dist/exception/invalid-value-exception.js.map +1 -0
- package/dist/fqn/common-fqn.d.ts +6 -2
- package/dist/fqn/common-fqn.js +56 -42
- package/dist/fqn/common-fqn.js.map +1 -1
- package/dist/fqn/index-types.d.ts +13 -2
- package/dist/fqn/index.d.ts +0 -1
- package/dist/fqn/index.js +0 -1
- package/dist/fqn/index.js.map +1 -1
- package/dist/hook/common-hook.d.ts +8 -6
- package/dist/hook/common-hook.js +23 -18
- package/dist/hook/common-hook.js.map +1 -1
- package/dist/hook/index-types.d.ts +27 -12
- package/dist/hook/index.d.ts +0 -1
- package/dist/hook/index.js +0 -1
- package/dist/hook/index.js.map +1 -1
- package/dist/index.d.ts +27 -12
- package/dist/index.js +29 -22
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +2 -0
- package/dist/internal.js +3 -1
- package/dist/internal.js.map +1 -1
- package/dist/is/common-is.d.ts +14 -0
- package/dist/is/common-is.js +53 -9
- package/dist/is/common-is.js.map +1 -1
- package/dist/is/index-types.d.ts +46 -1
- package/dist/is/index.d.ts +0 -1
- package/dist/is/index.js +0 -1
- package/dist/is/index.js.map +1 -1
- package/dist/leyyo/index-types.d.ts +14 -3
- package/dist/leyyo/index.d.ts +1 -1
- package/dist/leyyo/index.js +1 -1
- package/dist/leyyo/index.js.map +1 -1
- package/dist/leyyo/leyyo-common-hook.d.ts +10 -0
- package/dist/leyyo/leyyo-common-hook.js +18 -0
- package/dist/leyyo/leyyo-common-hook.js.map +1 -0
- package/dist/leyyo/leyyo.d.ts +17 -10
- package/dist/leyyo/leyyo.js +64 -83
- package/dist/leyyo/leyyo.js.map +1 -1
- package/dist/log/common-log.d.ts +2 -2
- package/dist/log/common-log.js +47 -15
- package/dist/log/common-log.js.map +1 -1
- package/dist/log/index-types.d.ts +55 -1
- package/dist/log/index.d.ts +1 -1
- package/dist/log/index.js +1 -1
- package/dist/log/index.js.map +1 -1
- package/dist/log/logger-instance.d.ts +16 -9
- package/dist/log/logger-instance.js +37 -8
- package/dist/log/logger-instance.js.map +1 -1
- package/dist/log/severity.js.map +1 -0
- package/dist/repo/common-repo.d.ts +44 -0
- package/dist/repo/common-repo.js +180 -0
- package/dist/repo/common-repo.js.map +1 -0
- package/dist/repo/index-types.d.ts +104 -0
- package/dist/repo/index-types.js +3 -0
- package/dist/{literal → repo}/index-types.js.map +1 -1
- package/dist/repo/index.d.ts +2 -0
- package/dist/repo/index.js +19 -0
- package/dist/repo/index.js.map +1 -0
- package/dist/repo/repo-type.d.ts +8 -0
- package/dist/repo/repo-type.js +8 -0
- package/dist/repo/repo-type.js.map +1 -0
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/dist/shared/index-types.d.ts +162 -132
- package/dist/shared/index-types.js +1 -1
- package/dist/shared/index-types.js.map +1 -1
- package/dist/shared/index.d.ts +0 -4
- package/dist/shared/index.js +0 -4
- package/dist/shared/index.js.map +1 -1
- package/dist/system/common-system.js +30 -3
- package/dist/system/common-system.js.map +1 -1
- package/dist/{literal → system}/country-code.js.map +1 -1
- package/dist/system/environment.js.map +1 -0
- package/dist/system/http-method.js.map +1 -0
- package/dist/system/http-place.js.map +1 -0
- package/dist/system/index.d.ts +8 -1
- package/dist/system/index.js +8 -1
- package/dist/system/index.js.map +1 -1
- package/dist/system/language-code.js.map +1 -0
- package/dist/system/locale-code.js.map +1 -0
- package/dist/system/sys-class.js.map +1 -0
- package/dist/system/sys-function.js.map +1 -0
- package/dist/to/common-to.d.ts +28 -21
- package/dist/to/common-to.js +541 -227
- package/dist/to/common-to.js.map +1 -1
- package/dist/to/index-types.d.ts +36 -16
- package/dist/to/index.d.ts +6 -1
- package/dist/to/index.js +6 -1
- package/dist/to/index.js.map +1 -1
- package/dist/to/key-value.js.map +1 -0
- package/dist/{shared → to}/list.d.ts +1 -0
- package/dist/{shared → to}/list.js +3 -0
- package/dist/to/list.js.map +1 -0
- package/dist/to/primitive.js.map +1 -0
- package/dist/to/real-value.js.map +1 -0
- package/dist/to/weak-false.js.map +1 -0
- package/dist/to/weak-true.js.map +1 -0
- package/dist/wrapper/common-wrapper.d.ts +26 -0
- package/dist/wrapper/common-wrapper.js +81 -0
- package/dist/wrapper/common-wrapper.js.map +1 -0
- package/dist/wrapper/index-types.d.ts +29 -0
- package/dist/wrapper/index-types.js +3 -0
- package/dist/{storage → wrapper}/index-types.js.map +1 -1
- package/dist/wrapper/index.d.ts +2 -0
- package/dist/wrapper/index.js +19 -0
- package/dist/wrapper/index.js.map +1 -0
- package/dist/wrapper/wrap.d.ts +7 -0
- package/dist/wrapper/wrap.js +11 -0
- package/dist/wrapper/wrap.js.map +1 -0
- package/package.json +13 -15
- package/dist/literal/environment.js.map +0 -1
- package/dist/literal/http-method.js.map +0 -1
- package/dist/literal/http-place.js.map +0 -1
- package/dist/literal/index-types.d.ts +0 -6
- package/dist/literal/index.d.ts +0 -16
- package/dist/literal/index.js.map +0 -1
- package/dist/literal/key-value.js.map +0 -1
- package/dist/literal/language-code.js.map +0 -1
- package/dist/literal/locale-code.js.map +0 -1
- package/dist/literal/primitive.js.map +0 -1
- package/dist/literal/real-value.js.map +0 -1
- package/dist/literal/severity.js.map +0 -1
- package/dist/literal/storage-type.d.ts +0 -8
- package/dist/literal/storage-type.js +0 -8
- package/dist/literal/storage-type.js.map +0 -1
- package/dist/literal/sys-class.js.map +0 -1
- package/dist/literal/sys-function.js.map +0 -1
- package/dist/literal/weak-false.js.map +0 -1
- package/dist/literal/weak-true.js.map +0 -1
- package/dist/shared/assert.d.ts +0 -6
- package/dist/shared/assert.js +0 -15
- package/dist/shared/assert.js.map +0 -1
- package/dist/shared/index-aliases.d.ts +0 -167
- package/dist/shared/index-aliases.js +0 -5
- package/dist/shared/index-aliases.js.map +0 -1
- package/dist/shared/index-constants.d.ts +0 -19
- package/dist/shared/index-constants.js +0 -23
- package/dist/shared/index-constants.js.map +0 -1
- package/dist/shared/list.js.map +0 -1
- package/dist/storage/common-storage.d.ts +0 -47
- package/dist/storage/common-storage.js +0 -151
- package/dist/storage/common-storage.js.map +0 -1
- package/dist/storage/index-types.d.ts +0 -87
- package/dist/storage/index.d.ts +0 -2
- package/dist/storage/index.js.map +0 -1
- /package/dist/{literal → descriptor}/index-types.js +0 -0
- /package/dist/{storage → developer}/index-types.js +0 -0
- /package/dist/{literal → log}/severity.d.ts +0 -0
- /package/dist/{literal → log}/severity.js +0 -0
- /package/dist/{literal → system}/country-code.d.ts +0 -0
- /package/dist/{literal → system}/country-code.js +0 -0
- /package/dist/{literal → system}/environment.d.ts +0 -0
- /package/dist/{literal → system}/environment.js +0 -0
- /package/dist/{literal → system}/http-method.d.ts +0 -0
- /package/dist/{literal → system}/http-method.js +0 -0
- /package/dist/{literal → system}/http-place.d.ts +0 -0
- /package/dist/{literal → system}/http-place.js +0 -0
- /package/dist/{literal → system}/language-code.d.ts +0 -0
- /package/dist/{literal → system}/language-code.js +0 -0
- /package/dist/{literal → system}/locale-code.d.ts +0 -0
- /package/dist/{literal → system}/locale-code.js +0 -0
- /package/dist/{literal → system}/sys-class.d.ts +0 -0
- /package/dist/{literal → system}/sys-class.js +0 -0
- /package/dist/{literal → system}/sys-function.d.ts +0 -0
- /package/dist/{literal → system}/sys-function.js +0 -0
- /package/dist/{literal → to}/key-value.d.ts +0 -0
- /package/dist/{literal → to}/key-value.js +0 -0
- /package/dist/{literal → to}/primitive.d.ts +0 -0
- /package/dist/{literal → to}/primitive.js +0 -0
- /package/dist/{literal → to}/real-value.d.ts +0 -0
- /package/dist/{literal → to}/real-value.js +0 -0
- /package/dist/{literal → to}/weak-false.d.ts +0 -0
- /package/dist/{literal → to}/weak-false.js +0 -0
- /package/dist/{literal → to}/weak-true.d.ts +0 -0
- /package/dist/{literal → to}/weak-true.js +0 -0
|
@@ -1,61 +1,50 @@
|
|
|
1
|
-
import { CommonAssertionLike, CommonAssertionSecure } from "./index-types";
|
|
1
|
+
import { AssertionCallback, CommonAssertionLike, CommonAssertionSecure } from "./index-types";
|
|
2
2
|
import { LeyyoLike } from "../leyyo";
|
|
3
|
-
import {
|
|
3
|
+
import { DevOpt } from "../developer";
|
|
4
4
|
/** @inheritDoc */
|
|
5
5
|
export declare class CommonAssertion implements CommonAssertionLike, CommonAssertionSecure {
|
|
6
|
-
private
|
|
7
|
-
private
|
|
6
|
+
private dev;
|
|
7
|
+
private readonly _EMPTY;
|
|
8
8
|
constructor();
|
|
9
|
-
|
|
10
|
-
* Build error parameters as message and params
|
|
11
|
-
* */
|
|
12
|
-
private buildErrorParameters;
|
|
13
|
-
/**
|
|
14
|
-
* Inner secure json function, it will be used after creating weak set
|
|
15
|
-
* */
|
|
16
|
-
_secureJson(value: unknown, level: number, set: WeakSet<Obj>): unknown;
|
|
9
|
+
private _run;
|
|
17
10
|
/** @inheritDoc */
|
|
18
|
-
|
|
11
|
+
array(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
19
12
|
/** @inheritDoc */
|
|
20
|
-
|
|
13
|
+
boolean(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
21
14
|
/** @inheritDoc */
|
|
22
|
-
|
|
15
|
+
clazz(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
23
16
|
/** @inheritDoc */
|
|
24
|
-
|
|
17
|
+
date(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
25
18
|
/** @inheritDoc */
|
|
26
|
-
|
|
19
|
+
func(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
27
20
|
/** @inheritDoc */
|
|
28
|
-
|
|
21
|
+
sym(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
29
22
|
/** @inheritDoc */
|
|
30
|
-
|
|
23
|
+
integer(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
31
24
|
/** @inheritDoc */
|
|
32
|
-
|
|
25
|
+
key(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
33
26
|
/** @inheritDoc */
|
|
34
|
-
|
|
27
|
+
notEmpty(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
35
28
|
/** @inheritDoc */
|
|
36
|
-
|
|
29
|
+
number(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
37
30
|
/** @inheritDoc */
|
|
38
|
-
|
|
31
|
+
object(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
39
32
|
/** @inheritDoc */
|
|
40
|
-
|
|
33
|
+
bareObject(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
41
34
|
/** @inheritDoc */
|
|
42
|
-
|
|
35
|
+
positiveInteger(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
43
36
|
/** @inheritDoc */
|
|
44
|
-
|
|
37
|
+
safeInteger(value: any, opt?: string | AssertionCallback | DevOpt): void;
|
|
45
38
|
/** @inheritDoc */
|
|
46
|
-
|
|
39
|
+
positiveNumber(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
47
40
|
/** @inheritDoc */
|
|
48
|
-
|
|
41
|
+
primitive(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
49
42
|
/** @inheritDoc */
|
|
50
|
-
|
|
43
|
+
string(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
51
44
|
/** @inheritDoc */
|
|
52
|
-
|
|
45
|
+
text(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
53
46
|
/** @inheritDoc */
|
|
54
|
-
|
|
55
|
-
/** @inheritDoc */
|
|
56
|
-
text(value: unknown, opt?: string | AssertionOpt | AssertionCallback): string;
|
|
57
|
-
/** @inheritDoc */
|
|
58
|
-
realValue(value: unknown, opt?: string | AssertionOpt | AssertionCallback): void;
|
|
47
|
+
realValue(value: unknown, opt?: string | DevOpt | AssertionCallback): void;
|
|
59
48
|
/** @inheritDoc */
|
|
60
49
|
get $back(): CommonAssertionLike;
|
|
61
50
|
/** @inheritDoc */
|
|
@@ -1,232 +1,161 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommonAssertion = void 0;
|
|
4
|
-
const
|
|
4
|
+
const internal_1 = require("../internal");
|
|
5
|
+
const to_1 = require("../to");
|
|
5
6
|
// noinspection JSUnusedGlobalSymbols
|
|
6
7
|
/** @inheritDoc */
|
|
7
8
|
class CommonAssertion {
|
|
8
9
|
// endregion properties
|
|
9
10
|
constructor() {
|
|
11
|
+
this._EMPTY = [null, undefined];
|
|
10
12
|
}
|
|
11
13
|
// region internal
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
buildErrorParameters(v2, indicator) {
|
|
16
|
-
if (typeof v2 === 'string') {
|
|
17
|
-
return { message: v2, params: { indicator } };
|
|
18
|
-
}
|
|
19
|
-
if (v2 && typeof v2 === 'object' && !Array.isArray(v2)) {
|
|
20
|
-
const params = v2;
|
|
21
|
-
if (params.indicator !== undefined) {
|
|
22
|
-
params.indicator2 = params.indicator;
|
|
23
|
-
params.indicator = indicator;
|
|
24
|
-
}
|
|
25
|
-
return { params };
|
|
14
|
+
_run(opt) {
|
|
15
|
+
if (typeof opt === 'string') {
|
|
16
|
+
return { issue: opt };
|
|
26
17
|
}
|
|
27
|
-
if (typeof
|
|
18
|
+
else if (typeof opt === 'function') {
|
|
28
19
|
try {
|
|
29
|
-
return this.
|
|
20
|
+
return this._run(opt());
|
|
30
21
|
}
|
|
31
22
|
catch (e) {
|
|
32
|
-
|
|
23
|
+
const key = `cv[${Date.now()}]`;
|
|
24
|
+
return {
|
|
25
|
+
[key]: [e.message, e.name]
|
|
26
|
+
};
|
|
33
27
|
}
|
|
34
28
|
}
|
|
35
|
-
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
const json = this.secureJson(v2);
|
|
39
|
-
if (json && typeof json === 'object' && !Array.isArray(json)) {
|
|
40
|
-
return { params: Object.assign(Object.assign({}, json), { indicator }) };
|
|
29
|
+
else {
|
|
30
|
+
return opt;
|
|
41
31
|
}
|
|
42
|
-
return { params: { json, indicator } };
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Inner secure json function, it will be used after creating weak set
|
|
46
|
-
* */
|
|
47
|
-
_secureJson(value, level, set) {
|
|
48
|
-
if ([null, undefined].includes(value)) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
switch (typeof value) {
|
|
52
|
-
case 'object':
|
|
53
|
-
if (set.has(value)) {
|
|
54
|
-
return `<circular>${this.fqn.name(value === null || value === void 0 ? void 0 : value.constructor)}`;
|
|
55
|
-
}
|
|
56
|
-
if (level >= 10) {
|
|
57
|
-
return `<max-depth>${this.fqn.name(value === null || value === void 0 ? void 0 : value.constructor)}`;
|
|
58
|
-
}
|
|
59
|
-
set.add(value);
|
|
60
|
-
if (Array.isArray(value)) {
|
|
61
|
-
return value.map(item => this._secureJson(item, level + 1, set));
|
|
62
|
-
}
|
|
63
|
-
const obj = {};
|
|
64
|
-
if (value instanceof Map) {
|
|
65
|
-
for (const [k, v] of value.entries()) {
|
|
66
|
-
obj[k] = JSON.parse(JSON.stringify(this._secureJson(v, level + 1, set)));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else if (value instanceof Set) {
|
|
70
|
-
return Array.from(value).map(item => this._secureJson(item, level + 1, set));
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
for (const [k, v] of Object.entries(value)) {
|
|
74
|
-
obj[k] = JSON.parse(JSON.stringify(this._secureJson(v, level + 1, set)));
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return obj;
|
|
78
|
-
case 'function':
|
|
79
|
-
return `<function>${this.fqn.name(value)}`;
|
|
80
|
-
case 'symbol':
|
|
81
|
-
return `<symbol>${value.toString()}`;
|
|
82
|
-
}
|
|
83
|
-
return value;
|
|
84
32
|
}
|
|
85
33
|
// endregion internal
|
|
86
|
-
// region raise
|
|
87
|
-
/** @inheritDoc */
|
|
88
|
-
raise(opt, value, indicator, def) {
|
|
89
|
-
const { message, params } = this.buildErrorParameters(opt, indicator);
|
|
90
|
-
const type = typeof value;
|
|
91
|
-
switch (type) {
|
|
92
|
-
case "object":
|
|
93
|
-
params.type = `object(${this.fqn.name(value.constructor)})`;
|
|
94
|
-
break;
|
|
95
|
-
case "function":
|
|
96
|
-
params.type = `function(${this.fqn.name(value)})`;
|
|
97
|
-
break;
|
|
98
|
-
default:
|
|
99
|
-
params.type = type;
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
def = def !== null && def !== void 0 ? def : 'Assertion error';
|
|
103
|
-
throw new exception_1.AssertionException(message !== null && message !== void 0 ? message : def, params);
|
|
104
|
-
}
|
|
105
|
-
/** @inheritDoc */
|
|
106
|
-
// noinspection JSUnusedLocalSymbols
|
|
107
|
-
emptyFn(...params) {
|
|
108
|
-
}
|
|
109
|
-
/** @inheritDoc */
|
|
110
|
-
secureJson(value) {
|
|
111
|
-
return this._secureJson(value, 0, new WeakSet());
|
|
112
|
-
}
|
|
113
|
-
// endregion raise
|
|
114
34
|
// region types
|
|
115
35
|
/** @inheritDoc */
|
|
116
36
|
array(value, opt) {
|
|
117
|
-
if (!
|
|
118
|
-
this.
|
|
37
|
+
if (!Array.isArray(value)) {
|
|
38
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.array', value, type: typeof value });
|
|
119
39
|
}
|
|
120
40
|
}
|
|
121
41
|
/** @inheritDoc */
|
|
122
42
|
boolean(value, opt) {
|
|
123
|
-
if (
|
|
124
|
-
this.
|
|
43
|
+
if (typeof value !== 'boolean') {
|
|
44
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.boolean', value, type: typeof value });
|
|
125
45
|
}
|
|
126
46
|
}
|
|
127
47
|
/** @inheritDoc */
|
|
128
48
|
clazz(value, opt) {
|
|
129
|
-
|
|
130
|
-
|
|
49
|
+
switch (typeof value) {
|
|
50
|
+
case "function":
|
|
51
|
+
return;
|
|
52
|
+
case "object":
|
|
53
|
+
if (!value) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
case "string":
|
|
58
|
+
if (value.trim() !== '') {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
131
62
|
}
|
|
63
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.class', value, type: typeof value });
|
|
132
64
|
}
|
|
133
65
|
/** @inheritDoc */
|
|
134
66
|
date(value, opt) {
|
|
135
67
|
if (!(value instanceof Date)) {
|
|
136
|
-
this.
|
|
68
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.date', value, type: typeof value });
|
|
137
69
|
}
|
|
138
70
|
}
|
|
139
71
|
/** @inheritDoc */
|
|
140
72
|
func(value, opt) {
|
|
141
|
-
if (
|
|
142
|
-
this.
|
|
73
|
+
if (typeof value !== 'function') {
|
|
74
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.function', value, type: typeof value });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/** @inheritDoc */
|
|
78
|
+
sym(value, opt) {
|
|
79
|
+
if (typeof value !== 'symbol') {
|
|
80
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.symbol', value, type: typeof value });
|
|
143
81
|
}
|
|
144
82
|
}
|
|
145
83
|
/** @inheritDoc */
|
|
146
84
|
integer(value, opt) {
|
|
147
|
-
if (!
|
|
148
|
-
this.
|
|
85
|
+
if (!Number.isInteger(value)) {
|
|
86
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.integer', value, type: typeof value });
|
|
149
87
|
}
|
|
150
88
|
}
|
|
151
89
|
/** @inheritDoc */
|
|
152
90
|
key(value, opt) {
|
|
153
|
-
if (!
|
|
154
|
-
this.
|
|
91
|
+
if (!['string', 'number'].includes(typeof value)) {
|
|
92
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.key', value, type: typeof value });
|
|
155
93
|
}
|
|
156
94
|
}
|
|
157
95
|
/** @inheritDoc */
|
|
158
96
|
notEmpty(value, opt) {
|
|
159
|
-
if (this.
|
|
160
|
-
this.
|
|
97
|
+
if (this._EMPTY.includes(value)) {
|
|
98
|
+
this.dev.invalid(this._run(opt), { issue: 'empty', value, type: typeof value });
|
|
161
99
|
}
|
|
162
100
|
}
|
|
163
101
|
/** @inheritDoc */
|
|
164
102
|
number(value, opt) {
|
|
165
|
-
if (
|
|
166
|
-
this.
|
|
103
|
+
if (typeof value !== 'number') {
|
|
104
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.number', value, type: typeof value });
|
|
167
105
|
}
|
|
168
106
|
}
|
|
169
107
|
/** @inheritDoc */
|
|
170
|
-
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
opt = {};
|
|
174
|
-
}
|
|
175
|
-
if (!opt.silent) {
|
|
176
|
-
delete opt.silent;
|
|
177
|
-
this.raise(opt, value, 'not.real.number', 'Not real number');
|
|
178
|
-
}
|
|
179
|
-
return null;
|
|
108
|
+
object(value, opt) {
|
|
109
|
+
if (!value || typeof value !== 'object' && !Array.isArray(value)) {
|
|
110
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.object', value, type: typeof value });
|
|
180
111
|
}
|
|
181
|
-
return value;
|
|
182
112
|
}
|
|
183
113
|
/** @inheritDoc */
|
|
184
|
-
|
|
185
|
-
if (!
|
|
186
|
-
this.
|
|
114
|
+
bareObject(value, opt) {
|
|
115
|
+
if (!value || typeof value !== 'object' && value.constructor !== Object) {
|
|
116
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.bare.object', value, type: typeof value });
|
|
187
117
|
}
|
|
188
118
|
}
|
|
189
119
|
/** @inheritDoc */
|
|
190
120
|
positiveInteger(value, opt) {
|
|
191
|
-
if (!
|
|
192
|
-
this.
|
|
121
|
+
if (!Number.isInteger(value) || (value <= 0)) {
|
|
122
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.positive.integer', value, type: typeof value });
|
|
193
123
|
}
|
|
194
124
|
}
|
|
195
125
|
/** @inheritDoc */
|
|
196
126
|
safeInteger(value, opt) {
|
|
197
|
-
if (!
|
|
198
|
-
this.
|
|
127
|
+
if (!Number.isSafeInteger(value)) {
|
|
128
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.safe.integer', value, type: typeof value });
|
|
199
129
|
}
|
|
200
130
|
}
|
|
201
131
|
/** @inheritDoc */
|
|
202
132
|
positiveNumber(value, opt) {
|
|
203
|
-
if (
|
|
204
|
-
this.
|
|
133
|
+
if (typeof value !== 'number' || (value <= 0)) {
|
|
134
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.positive', value, type: typeof value });
|
|
205
135
|
}
|
|
206
136
|
}
|
|
207
137
|
/** @inheritDoc */
|
|
208
138
|
primitive(value, opt) {
|
|
209
|
-
if (!
|
|
210
|
-
this.
|
|
139
|
+
if (!to_1.PrimitiveItems.includes(typeof value)) {
|
|
140
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.primitive', value, type: typeof value });
|
|
211
141
|
}
|
|
212
142
|
}
|
|
213
143
|
/** @inheritDoc */
|
|
214
144
|
string(value, opt) {
|
|
215
|
-
if (
|
|
216
|
-
this.
|
|
145
|
+
if (typeof value !== 'string') {
|
|
146
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.string', value, type: typeof value });
|
|
217
147
|
}
|
|
218
148
|
}
|
|
219
149
|
/** @inheritDoc */
|
|
220
150
|
text(value, opt) {
|
|
221
|
-
if (
|
|
222
|
-
this.
|
|
151
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
152
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.text', value, type: typeof value });
|
|
223
153
|
}
|
|
224
|
-
return value.trim();
|
|
225
154
|
}
|
|
226
155
|
/** @inheritDoc */
|
|
227
156
|
realValue(value, opt) {
|
|
228
|
-
if (!
|
|
229
|
-
this.
|
|
157
|
+
if (!to_1.RealValueItems.includes(typeof value)) {
|
|
158
|
+
this.dev.invalid(this._run(opt), { issue: 'invalid.real.value', value, type: typeof value });
|
|
230
159
|
}
|
|
231
160
|
}
|
|
232
161
|
// endregion types
|
|
@@ -237,8 +166,10 @@ class CommonAssertion {
|
|
|
237
166
|
}
|
|
238
167
|
/** @inheritDoc */
|
|
239
168
|
$init(leyyo) {
|
|
240
|
-
this.
|
|
241
|
-
|
|
169
|
+
this.dev = leyyo.dev;
|
|
170
|
+
leyyo.$secure.$lazyRun(() => {
|
|
171
|
+
leyyo.fqn.register(null, CommonAssertion, 'class', internal_1.FQN_PCK);
|
|
172
|
+
});
|
|
242
173
|
}
|
|
243
174
|
/** @inheritDoc */
|
|
244
175
|
get $secure() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common-assertion.js","sourceRoot":"","sources":["../../src/assertion/common-assertion.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"common-assertion.js","sourceRoot":"","sources":["../../src/assertion/common-assertion.ts"],"names":[],"mappings":";;;AAGA,0CAAoC;AACpC,8BAA2E;AAE3E,qCAAqC;AACrC,kBAAkB;AAClB,MAAa,eAAe;IAKxB,uBAAuB;IAEvB;QAJiB,WAAM,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAK5C,CAAC;IAED,kBAAkB;IACV,IAAI,CAAC,GAAwC;QACjD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC1B,OAAO,EAAC,KAAK,EAAE,GAAG,EAAC,CAAC;QACxB,CAAC;aAAM,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;YACnC,IAAI,CAAC;gBACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;YAC5B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,GAAa,CAAC;gBAC1C,OAAO;oBACH,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAA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