@duplojs/lang 0.0.1-beta.6 → 0.0.1-beta.8
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/chrono/createDate.cjs +8 -8
- package/dist/chrono/createDate.d.ts +3 -3
- package/dist/chrono/createDate.mjs +8 -8
- package/dist/chrono/createTime.cjs +24 -13
- package/dist/chrono/createTime.mjs +24 -13
- package/dist/chrono/theDate.cjs +15 -16
- package/dist/chrono/theDate.d.ts +15 -15
- package/dist/chrono/theDate.mjs +15 -16
- package/dist/chrono/theTime.cjs +0 -1
- package/dist/chrono/theTime.mjs +0 -1
- package/dist/chrono/types/spoolingTime.d.ts +2 -1
- package/dist/common/constraint/cast/string.d.ts +4 -0
- package/dist/common/constraint/infer/string.d.ts +1 -0
- package/dist/common/isType.d.ts +3 -2
- package/dist/common/types/json.d.ts +1 -1
- package/dist/dataStructure/common/{codec.cjs → codec/base.cjs} +5 -5
- package/dist/dataStructure/common/{codec.d.ts → codec/base.d.ts} +6 -6
- package/dist/dataStructure/common/{codec.mjs → codec/base.mjs} +5 -5
- package/dist/dataStructure/common/codec/defaults/index.d.ts +2 -0
- package/dist/dataStructure/common/codec/defaults/json.cjs +26 -0
- package/dist/dataStructure/common/codec/defaults/json.d.ts +6 -0
- package/dist/dataStructure/common/codec/defaults/json.mjs +26 -0
- package/dist/dataStructure/common/codec/defaults/string.cjs +44 -0
- package/dist/dataStructure/common/codec/defaults/string.d.ts +11 -0
- package/dist/dataStructure/common/codec/defaults/string.mjs +44 -0
- package/dist/dataStructure/common/codec/index.d.ts +2 -0
- package/dist/dataStructure/constraint/base.cjs +18 -2
- package/dist/dataStructure/constraint/base.d.ts +5 -0
- package/dist/dataStructure/constraint/base.mjs +18 -3
- package/dist/dataStructure/constraint/defaults/index.d.ts +1 -0
- package/dist/dataStructure/constraint/defaults/numberInString.cjs +13 -0
- package/dist/dataStructure/constraint/defaults/numberInString.d.ts +10 -0
- package/dist/dataStructure/constraint/defaults/numberInString.mjs +12 -0
- package/dist/dataStructure/constraint/types/constraints.d.ts +1 -0
- package/dist/dataStructure/helpers/index.d.ts +1 -0
- package/dist/dataStructure/helpers/numberInString.cjs +7 -0
- package/dist/dataStructure/helpers/numberInString.d.ts +2 -0
- package/dist/dataStructure/helpers/numberInString.mjs +7 -0
- package/dist/dataStructure/index.cjs +65 -49
- package/dist/dataStructure/index.mjs +23 -13
- package/dist/modeling/entity/base.d.ts +2 -2
- package/dist/modeling/taggedObject/base.cjs +64 -1
- package/dist/modeling/taggedObject/base.d.ts +19 -1
- package/dist/modeling/taggedObject/base.mjs +64 -1
- package/dist/number/types/isGreater.d.ts +5 -5
- package/dist/path/getParentFolderPath.cjs +6 -2
- package/dist/path/getParentFolderPath.d.ts +1 -1
- package/dist/path/getParentFolderPath.mjs +6 -2
- package/dist/string/constraints/index.d.ts +2 -1
- package/dist/string/constraints/number.d.ts +4 -0
- package/dist/string/index.cjs +3 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.mjs +3 -1
- package/dist/string/isNumber.cjs +7 -0
- package/dist/string/isNumber.d.ts +5 -0
- package/dist/string/isNumber.mjs +7 -0
- package/dist/string/to.d.ts +9 -2
- package/dist/string/types/index.d.ts +4 -5
- package/dist/string/types/numberInString.d.ts +1 -0
- package/package.json +1 -1
- package/dist/string/types/number.d.ts +0 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const require_whenHasInformationOtherwise = require("../../../../either/whenHasInformationOtherwise.cjs");
|
|
2
|
+
const require_createDate = require("../../../../chrono/createDate.cjs");
|
|
3
|
+
const require_createTime = require("../../../../chrono/createTime.cjs");
|
|
4
|
+
const require_forward = require("../../../../common/forward.cjs");
|
|
5
|
+
const require_innerPipe = require("../../../../common/innerPipe.cjs");
|
|
6
|
+
const require_justReturn = require("../../../../common/justReturn.cjs");
|
|
7
|
+
const require_to = require("../../../../string/to.cjs");
|
|
8
|
+
const require_resultSymbol = require("../../resultSymbol.cjs");
|
|
9
|
+
const require_base = require("../base.cjs");
|
|
10
|
+
const require_bigint = require("../../../fundamentalType/defaults/bigint.cjs");
|
|
11
|
+
const require_date = require("../../../fundamentalType/defaults/date.cjs");
|
|
12
|
+
const require_time = require("../../../fundamentalType/defaults/time.cjs");
|
|
13
|
+
//#region scripts/dataStructure/common/codec/defaults/json.ts
|
|
14
|
+
const codecsJson = require_base.createCodecs({
|
|
15
|
+
bigint: require_base.createCodec(require_bigint.TheBigint, (data) => typeof data === "string", require_to.to, (data) => {
|
|
16
|
+
try {
|
|
17
|
+
return BigInt(data);
|
|
18
|
+
} catch {
|
|
19
|
+
return require_resultSymbol.ErrorSymbol;
|
|
20
|
+
}
|
|
21
|
+
}),
|
|
22
|
+
date: require_base.createCodec(require_date.TheDate, (data) => typeof data === "string", require_to.to, require_innerPipe.innerPipe((value) => require_createDate.createDate({ value }), require_whenHasInformationOtherwise.whenHasInformationOtherwise("date-created", require_forward.forward, require_justReturn.justReturn(require_resultSymbol.ErrorSymbol)))),
|
|
23
|
+
time: require_base.createCodec(require_time.TheTime, (data) => typeof data === "string", require_to.to, require_innerPipe.innerPipe((value) => require_createTime.createTime({ value }), require_whenHasInformationOtherwise.whenHasInformationOtherwise("time-created", require_forward.forward, require_justReturn.justReturn(require_resultSymbol.ErrorSymbol))))
|
|
24
|
+
});
|
|
25
|
+
//#endregion
|
|
26
|
+
exports.codecsJson = codecsJson;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as FundamentalType from "../../../fundamentalType";
|
|
2
|
+
export declare const codecsJson: import('../../..').Codecs<{
|
|
3
|
+
bigint: import('../../..').Codec<FundamentalType.TheBigint, string>;
|
|
4
|
+
date: import('../../..').Codec<FundamentalType.TheDate, string>;
|
|
5
|
+
time: import('../../..').Codec<FundamentalType.TheTime, string>;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { whenHasInformationOtherwise } from "../../../../either/whenHasInformationOtherwise.mjs";
|
|
2
|
+
import { createDate } from "../../../../chrono/createDate.mjs";
|
|
3
|
+
import { createTime } from "../../../../chrono/createTime.mjs";
|
|
4
|
+
import { forward } from "../../../../common/forward.mjs";
|
|
5
|
+
import { innerPipe } from "../../../../common/innerPipe.mjs";
|
|
6
|
+
import { justReturn } from "../../../../common/justReturn.mjs";
|
|
7
|
+
import { to } from "../../../../string/to.mjs";
|
|
8
|
+
import { ErrorSymbol } from "../../resultSymbol.mjs";
|
|
9
|
+
import { createCodec, createCodecs } from "../base.mjs";
|
|
10
|
+
import { TheBigint } from "../../../fundamentalType/defaults/bigint.mjs";
|
|
11
|
+
import { TheDate } from "../../../fundamentalType/defaults/date.mjs";
|
|
12
|
+
import { TheTime } from "../../../fundamentalType/defaults/time.mjs";
|
|
13
|
+
//#region scripts/dataStructure/common/codec/defaults/json.ts
|
|
14
|
+
const codecsJson = createCodecs({
|
|
15
|
+
bigint: createCodec(TheBigint, (data) => typeof data === "string", to, (data) => {
|
|
16
|
+
try {
|
|
17
|
+
return BigInt(data);
|
|
18
|
+
} catch {
|
|
19
|
+
return ErrorSymbol;
|
|
20
|
+
}
|
|
21
|
+
}),
|
|
22
|
+
date: createCodec(TheDate, (data) => typeof data === "string", to, innerPipe((value) => createDate({ value }), whenHasInformationOtherwise("date-created", forward, justReturn(ErrorSymbol)))),
|
|
23
|
+
time: createCodec(TheTime, (data) => typeof data === "string", to, innerPipe((value) => createTime({ value }), whenHasInformationOtherwise("time-created", forward, justReturn(ErrorSymbol))))
|
|
24
|
+
});
|
|
25
|
+
//#endregion
|
|
26
|
+
export { codecsJson };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const require_whenHasInformationOtherwise = require("../../../../either/whenHasInformationOtherwise.cjs");
|
|
2
|
+
const require_createDate = require("../../../../chrono/createDate.cjs");
|
|
3
|
+
const require_createTime = require("../../../../chrono/createTime.cjs");
|
|
4
|
+
const require_forward = require("../../../../common/forward.cjs");
|
|
5
|
+
const require_innerPipe = require("../../../../common/innerPipe.cjs");
|
|
6
|
+
const require_justReturn = require("../../../../common/justReturn.cjs");
|
|
7
|
+
const require_isNumber = require("../../../../string/isNumber.cjs");
|
|
8
|
+
const require_to = require("../../../../string/to.cjs");
|
|
9
|
+
const require_resultSymbol = require("../../resultSymbol.cjs");
|
|
10
|
+
const require_base = require("../base.cjs");
|
|
11
|
+
const require_bigint = require("../../../fundamentalType/defaults/bigint.cjs");
|
|
12
|
+
const require_boolean = require("../../../fundamentalType/defaults/boolean.cjs");
|
|
13
|
+
const require_date = require("../../../fundamentalType/defaults/date.cjs");
|
|
14
|
+
const require_null = require("../../../fundamentalType/defaults/null.cjs");
|
|
15
|
+
const require_number = require("../../../fundamentalType/defaults/number.cjs");
|
|
16
|
+
const require_time = require("../../../fundamentalType/defaults/time.cjs");
|
|
17
|
+
const require_undefined = require("../../../fundamentalType/defaults/undefined.cjs");
|
|
18
|
+
//#region scripts/dataStructure/common/codec/defaults/string.ts
|
|
19
|
+
const codecsString = require_base.createCodecs({
|
|
20
|
+
bigint: require_base.createCodec(require_bigint.TheBigint, (data) => typeof data === "string", require_to.to, (data) => {
|
|
21
|
+
try {
|
|
22
|
+
return BigInt(data);
|
|
23
|
+
} catch {
|
|
24
|
+
return require_resultSymbol.ErrorSymbol;
|
|
25
|
+
}
|
|
26
|
+
}),
|
|
27
|
+
boolean: require_base.createCodec(require_boolean.TheBoolean, (data) => data === "true" || data === "false", require_to.to, (data) => {
|
|
28
|
+
if (data === "true") return true;
|
|
29
|
+
return false;
|
|
30
|
+
}),
|
|
31
|
+
date: require_base.createCodec(require_date.TheDate, (data) => typeof data === "string", require_to.to, require_innerPipe.innerPipe((value) => require_createDate.createDate({ value }), require_whenHasInformationOtherwise.whenHasInformationOtherwise("date-created", require_forward.forward, require_justReturn.justReturn(require_resultSymbol.ErrorSymbol)))),
|
|
32
|
+
null: require_base.createCodec(require_null.TheNull, (data) => data === "null", require_to.to, require_justReturn.justReturn(null)),
|
|
33
|
+
number: require_base.createCodec(require_number.TheNumber, (data) => typeof data === "string" && require_isNumber.isNumber(data), require_to.to, (data) => {
|
|
34
|
+
try {
|
|
35
|
+
return Number(data);
|
|
36
|
+
} catch {
|
|
37
|
+
return require_resultSymbol.ErrorSymbol;
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
time: require_base.createCodec(require_time.TheTime, (data) => typeof data === "string", require_to.to, require_innerPipe.innerPipe((value) => require_createTime.createTime({ value }), require_whenHasInformationOtherwise.whenHasInformationOtherwise("time-created", require_forward.forward, require_justReturn.justReturn(require_resultSymbol.ErrorSymbol)))),
|
|
41
|
+
undefined: require_base.createCodec(require_undefined.TheUndefined, (data) => data === "undefined", require_to.to, require_justReturn.justReturn(void 0))
|
|
42
|
+
});
|
|
43
|
+
//#endregion
|
|
44
|
+
exports.codecsString = codecsString;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as DString from '../../../../string';
|
|
2
|
+
import * as FundamentalType from "../../../fundamentalType";
|
|
3
|
+
export declare const codecsString: import('../../..').Codecs<{
|
|
4
|
+
bigint: import('../../..').Codec<FundamentalType.TheBigint, string>;
|
|
5
|
+
boolean: import('../../..').Codec<FundamentalType.TheBoolean, "true" | "false">;
|
|
6
|
+
date: import('../../..').Codec<FundamentalType.TheDate, string>;
|
|
7
|
+
null: import('../../..').Codec<FundamentalType.TheNull, "null">;
|
|
8
|
+
number: import('../../..').Codec<FundamentalType.TheNumber, string & DString.Number>;
|
|
9
|
+
time: import('../../..').Codec<FundamentalType.TheTime, string>;
|
|
10
|
+
undefined: import('../../..').Codec<FundamentalType.TheUndefined, "undefined">;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { whenHasInformationOtherwise } from "../../../../either/whenHasInformationOtherwise.mjs";
|
|
2
|
+
import { createDate } from "../../../../chrono/createDate.mjs";
|
|
3
|
+
import { createTime } from "../../../../chrono/createTime.mjs";
|
|
4
|
+
import { forward } from "../../../../common/forward.mjs";
|
|
5
|
+
import { innerPipe } from "../../../../common/innerPipe.mjs";
|
|
6
|
+
import { justReturn } from "../../../../common/justReturn.mjs";
|
|
7
|
+
import { isNumber } from "../../../../string/isNumber.mjs";
|
|
8
|
+
import { to } from "../../../../string/to.mjs";
|
|
9
|
+
import { ErrorSymbol } from "../../resultSymbol.mjs";
|
|
10
|
+
import { createCodec, createCodecs } from "../base.mjs";
|
|
11
|
+
import { TheBigint } from "../../../fundamentalType/defaults/bigint.mjs";
|
|
12
|
+
import { TheBoolean } from "../../../fundamentalType/defaults/boolean.mjs";
|
|
13
|
+
import { TheDate } from "../../../fundamentalType/defaults/date.mjs";
|
|
14
|
+
import { TheNull } from "../../../fundamentalType/defaults/null.mjs";
|
|
15
|
+
import { TheNumber } from "../../../fundamentalType/defaults/number.mjs";
|
|
16
|
+
import { TheTime } from "../../../fundamentalType/defaults/time.mjs";
|
|
17
|
+
import { TheUndefined } from "../../../fundamentalType/defaults/undefined.mjs";
|
|
18
|
+
//#region scripts/dataStructure/common/codec/defaults/string.ts
|
|
19
|
+
const codecsString = createCodecs({
|
|
20
|
+
bigint: createCodec(TheBigint, (data) => typeof data === "string", to, (data) => {
|
|
21
|
+
try {
|
|
22
|
+
return BigInt(data);
|
|
23
|
+
} catch {
|
|
24
|
+
return ErrorSymbol;
|
|
25
|
+
}
|
|
26
|
+
}),
|
|
27
|
+
boolean: createCodec(TheBoolean, (data) => data === "true" || data === "false", to, (data) => {
|
|
28
|
+
if (data === "true") return true;
|
|
29
|
+
return false;
|
|
30
|
+
}),
|
|
31
|
+
date: createCodec(TheDate, (data) => typeof data === "string", to, innerPipe((value) => createDate({ value }), whenHasInformationOtherwise("date-created", forward, justReturn(ErrorSymbol)))),
|
|
32
|
+
null: createCodec(TheNull, (data) => data === "null", to, justReturn(null)),
|
|
33
|
+
number: createCodec(TheNumber, (data) => typeof data === "string" && isNumber(data), to, (data) => {
|
|
34
|
+
try {
|
|
35
|
+
return Number(data);
|
|
36
|
+
} catch {
|
|
37
|
+
return ErrorSymbol;
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
time: createCodec(TheTime, (data) => typeof data === "string", to, innerPipe((value) => createTime({ value }), whenHasInformationOtherwise("time-created", forward, justReturn(ErrorSymbol)))),
|
|
41
|
+
undefined: createCodec(TheUndefined, (data) => data === "undefined", to, justReturn(void 0))
|
|
42
|
+
});
|
|
43
|
+
//#endregion
|
|
44
|
+
export { codecsString };
|
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
const require_bindPrototypeMethods = require("../../common/bindPrototypeMethods.cjs");
|
|
1
2
|
const require_simpleClone = require("../../common/simpleClone.cjs");
|
|
2
3
|
//#region scripts/dataStructure/constraint/base.ts
|
|
3
4
|
const constraintKind = require("../kind.cjs").createKind("constraint");
|
|
5
|
+
var ConstraintBase = class ConstraintBase {
|
|
6
|
+
constructor() {}
|
|
7
|
+
static init(params) {
|
|
8
|
+
const self = new ConstraintBase();
|
|
9
|
+
require_bindPrototypeMethods.bindPrototypeMethods(self);
|
|
10
|
+
for (const key in params) self[key] = params[key];
|
|
11
|
+
return self;
|
|
12
|
+
}
|
|
13
|
+
static addToPrototype(prop, value) {
|
|
14
|
+
ConstraintBase.prototype[prop] = typeof value === "function" ? function(...args) {
|
|
15
|
+
return value(this, ...args);
|
|
16
|
+
} : value;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
4
19
|
function createConstraint(kindHandler, createConstructor) {
|
|
5
20
|
const init = (definition, { executeCheck, isAsynchronous }) => {
|
|
6
|
-
const self = {
|
|
21
|
+
const self = ConstraintBase.init({
|
|
7
22
|
definition,
|
|
8
23
|
executeCheck: (data) => executeCheck(self, data),
|
|
9
24
|
isAsynchronous: () => isAsynchronous(self),
|
|
@@ -20,11 +35,12 @@ function createConstraint(kindHandler, createConstructor) {
|
|
|
20
35
|
},
|
|
21
36
|
[constraintKind.runTimeKey]: null,
|
|
22
37
|
[kindHandler.runTimeKey]: null
|
|
23
|
-
};
|
|
38
|
+
});
|
|
24
39
|
return self;
|
|
25
40
|
};
|
|
26
41
|
return createConstructor({ init });
|
|
27
42
|
}
|
|
28
43
|
//#endregion
|
|
44
|
+
exports.ConstraintBase = ConstraintBase;
|
|
29
45
|
exports.constraintKind = constraintKind;
|
|
30
46
|
exports.createConstraint = createConstraint;
|
|
@@ -19,6 +19,11 @@ export interface CreateConstraintInitParams<GenericConstraint extends Constraint
|
|
|
19
19
|
executeCheck(self: GenericConstraint, data: Parameters<GenericConstraint["executeCheck"]>[0]): DCommon.MaybePromise<SuccessSymbol | ErrorSymbol>;
|
|
20
20
|
isAsynchronous(self: GenericConstraint): boolean;
|
|
21
21
|
}
|
|
22
|
+
export declare class ConstraintBase {
|
|
23
|
+
private constructor();
|
|
24
|
+
static init(params: DKind.Remove<Constraint>): Constraint;
|
|
25
|
+
static addToPrototype<GenericProp extends keyof Constraint>(prop: GenericProp, value: Constraint[GenericProp] extends infer InferredValue ? InferredValue extends DCommon.AnyFunction ? (self: Constraint, ...rest: Parameters<InferredValue>) => ReturnType<InferredValue> : Constraint[GenericProp] : never): void;
|
|
26
|
+
}
|
|
22
27
|
export interface CreateConstraintConstructorParams<GenericKindHandler extends DKind.Handler = DKind.Handler> {
|
|
23
28
|
init<GenericConstraint extends (Constraint & DKind.Kind<GenericKindHandler>)>(definition: GenericConstraint["definition"], params: CreateConstraintInitParams<GenericConstraint>): GenericConstraint;
|
|
24
29
|
}
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
+
import { bindPrototypeMethods } from "../../common/bindPrototypeMethods.mjs";
|
|
1
2
|
import { simpleClone } from "../../common/simpleClone.mjs";
|
|
2
3
|
import { createKind } from "../kind.mjs";
|
|
3
4
|
//#region scripts/dataStructure/constraint/base.ts
|
|
4
5
|
const constraintKind = createKind("constraint");
|
|
6
|
+
var ConstraintBase = class ConstraintBase {
|
|
7
|
+
constructor() {}
|
|
8
|
+
static init(params) {
|
|
9
|
+
const self = new ConstraintBase();
|
|
10
|
+
bindPrototypeMethods(self);
|
|
11
|
+
for (const key in params) self[key] = params[key];
|
|
12
|
+
return self;
|
|
13
|
+
}
|
|
14
|
+
static addToPrototype(prop, value) {
|
|
15
|
+
ConstraintBase.prototype[prop] = typeof value === "function" ? function(...args) {
|
|
16
|
+
return value(this, ...args);
|
|
17
|
+
} : value;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
5
20
|
function createConstraint(kindHandler, createConstructor) {
|
|
6
21
|
const init = (definition, { executeCheck, isAsynchronous }) => {
|
|
7
|
-
const self = {
|
|
22
|
+
const self = ConstraintBase.init({
|
|
8
23
|
definition,
|
|
9
24
|
executeCheck: (data) => executeCheck(self, data),
|
|
10
25
|
isAsynchronous: () => isAsynchronous(self),
|
|
@@ -21,10 +36,10 @@ function createConstraint(kindHandler, createConstructor) {
|
|
|
21
36
|
},
|
|
22
37
|
[constraintKind.runTimeKey]: null,
|
|
23
38
|
[kindHandler.runTimeKey]: null
|
|
24
|
-
};
|
|
39
|
+
});
|
|
25
40
|
return self;
|
|
26
41
|
};
|
|
27
42
|
return createConstructor({ init });
|
|
28
43
|
}
|
|
29
44
|
//#endregion
|
|
30
|
-
export { constraintKind, createConstraint };
|
|
45
|
+
export { ConstraintBase, constraintKind, createConstraint };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const require_isNumber = require("../../../string/isNumber.cjs");
|
|
2
|
+
const require_kind = require("../../kind.cjs");
|
|
3
|
+
const require_resultSymbol = require("../../common/resultSymbol.cjs");
|
|
4
|
+
const require_base = require("../base.cjs");
|
|
5
|
+
//#region scripts/dataStructure/constraint/defaults/numberInString.ts
|
|
6
|
+
const numberInStringConstraintKind = require_kind.createKind("number-in-string-constraint");
|
|
7
|
+
const NumberInStringConstraint = require_base.createConstraint(numberInStringConstraintKind, ({ init }) => () => init({}, {
|
|
8
|
+
executeCheck: (_self, data) => require_isNumber.isNumber(data) ? require_resultSymbol.SuccessSymbol : require_resultSymbol.ErrorSymbol,
|
|
9
|
+
isAsynchronous: () => false
|
|
10
|
+
}));
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.NumberInStringConstraint = NumberInStringConstraint;
|
|
13
|
+
exports.numberInStringConstraintKind = numberInStringConstraintKind;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConstraintDefinition, Constraint } from '../base';
|
|
2
|
+
import type * as DCommon from '../../../common';
|
|
3
|
+
import type * as DKind from '../../../kind';
|
|
4
|
+
import * as DString from '../../../string';
|
|
5
|
+
export declare const numberInStringConstraintKind: DKind.Handler<DKind.Definition<"@DuplojsLangDataStructure/number-in-string-constraint", unknown>>;
|
|
6
|
+
export interface NumberInStringConstraintDefinition extends ConstraintDefinition {
|
|
7
|
+
}
|
|
8
|
+
export interface NumberInStringConstraint extends DCommon.Forward<Constraint<string, string & DString.Number, NumberInStringConstraintDefinition> & DKind.Kind<typeof numberInStringConstraintKind>> {
|
|
9
|
+
}
|
|
10
|
+
export declare const NumberInStringConstraint: () => NumberInStringConstraint;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { isNumber } from "../../../string/isNumber.mjs";
|
|
2
|
+
import { createKind } from "../../kind.mjs";
|
|
3
|
+
import { ErrorSymbol, SuccessSymbol } from "../../common/resultSymbol.mjs";
|
|
4
|
+
import { createConstraint } from "../base.mjs";
|
|
5
|
+
//#region scripts/dataStructure/constraint/defaults/numberInString.ts
|
|
6
|
+
const numberInStringConstraintKind = createKind("number-in-string-constraint");
|
|
7
|
+
const NumberInStringConstraint = createConstraint(numberInStringConstraintKind, ({ init }) => () => init({}, {
|
|
8
|
+
executeCheck: (_self, data) => isNumber(data) ? SuccessSymbol : ErrorSymbol,
|
|
9
|
+
isAsynchronous: () => false
|
|
10
|
+
}));
|
|
11
|
+
//#endregion
|
|
12
|
+
export { NumberInStringConstraint, numberInStringConstraintKind };
|
|
@@ -10,6 +10,7 @@ export interface ConstraintsStore {
|
|
|
10
10
|
regex: DDefaults.RegexConstraint;
|
|
11
11
|
minCharacters: DDefaults.MinCharactersConstraint;
|
|
12
12
|
maxCharacters: DDefaults.MaxCharactersConstraint;
|
|
13
|
+
numberInString: DDefaults.NumberInStringConstraint;
|
|
13
14
|
stringLengthEqual: DDefaults.StringLengthEqualConstraint;
|
|
14
15
|
minElements: DDefaults.MinElementsConstraint;
|
|
15
16
|
maxElements: DDefaults.MaxElementsConstraint;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const require_numberInString = require("../constraint/defaults/numberInString.cjs");
|
|
2
|
+
//#region scripts/dataStructure/helpers/numberInString.ts
|
|
3
|
+
function numberInString() {
|
|
4
|
+
return require_numberInString.NumberInStringConstraint();
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
exports.numberInString = numberInString;
|