@duplojs/utils 1.1.12 → 1.1.14
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/array/flat.cjs +1 -13
- package/dist/array/flat.d.ts +1 -4
- package/dist/array/flat.mjs +1 -13
- package/dist/array/index.cjs +2 -0
- package/dist/array/index.d.ts +1 -0
- package/dist/array/index.mjs +1 -0
- package/dist/array/notIncludes.cjs +12 -0
- package/dist/array/notIncludes.d.ts +4 -0
- package/dist/array/notIncludes.mjs +10 -0
- package/dist/array/reduce.d.ts +6 -7
- package/dist/array/reduceRight.d.ts +4 -3
- package/dist/common/createKindIdentifier.cjs +27 -0
- package/dist/common/createKindIdentifier.d.ts +7 -0
- package/dist/common/createKindIdentifier.mjs +25 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/kind.cjs +15 -12
- package/dist/common/kind.d.ts +2 -2
- package/dist/common/kind.mjs +15 -12
- package/dist/common/or.d.ts +9 -9
- package/dist/common/types/index.d.ts +2 -0
- package/dist/common/types/onlyLiteral.d.ts +18 -0
- package/dist/common/types/unwrapArray.d.ts +1 -0
- package/dist/dataParser/base.cjs +55 -29
- package/dist/dataParser/base.d.ts +1 -1
- package/dist/dataParser/base.mjs +55 -29
- package/dist/dataParser/baseExtended.cjs +15 -2
- package/dist/dataParser/baseExtended.d.ts +8 -3
- package/dist/dataParser/baseExtended.mjs +15 -2
- package/dist/dataParser/extended/array.cjs +1 -0
- package/dist/dataParser/extended/array.d.ts +11 -5
- package/dist/dataParser/extended/array.mjs +1 -0
- package/dist/dataParser/extended/bigint.cjs +1 -0
- package/dist/dataParser/extended/bigint.d.ts +9 -2
- package/dist/dataParser/extended/bigint.mjs +1 -0
- package/dist/dataParser/extended/boolean.cjs +1 -0
- package/dist/dataParser/extended/boolean.d.ts +13 -2
- package/dist/dataParser/extended/boolean.mjs +1 -0
- package/dist/dataParser/extended/coerce/bigint.cjs +1 -0
- package/dist/dataParser/extended/coerce/bigint.mjs +1 -0
- package/dist/dataParser/extended/coerce/boolean.cjs +1 -0
- package/dist/dataParser/extended/coerce/boolean.mjs +1 -0
- package/dist/dataParser/extended/coerce/empty.cjs +1 -0
- package/dist/dataParser/extended/coerce/empty.mjs +1 -0
- package/dist/dataParser/extended/coerce/nil.cjs +1 -0
- package/dist/dataParser/extended/coerce/nil.mjs +1 -0
- package/dist/dataParser/extended/coerce/number.cjs +1 -0
- package/dist/dataParser/extended/coerce/number.mjs +1 -0
- package/dist/dataParser/extended/coerce/string.cjs +1 -0
- package/dist/dataParser/extended/coerce/string.mjs +1 -0
- package/dist/dataParser/extended/empty.cjs +1 -0
- package/dist/dataParser/extended/empty.d.ts +13 -2
- package/dist/dataParser/extended/empty.mjs +1 -0
- package/dist/dataParser/extended/index.cjs +2 -0
- package/dist/dataParser/extended/index.d.ts +1 -0
- package/dist/dataParser/extended/index.mjs +1 -0
- package/dist/dataParser/extended/lazy.cjs +1 -0
- package/dist/dataParser/extended/lazy.d.ts +13 -3
- package/dist/dataParser/extended/lazy.mjs +1 -0
- package/dist/dataParser/extended/literal.cjs +1 -0
- package/dist/dataParser/extended/literal.d.ts +13 -2
- package/dist/dataParser/extended/literal.mjs +1 -0
- package/dist/dataParser/extended/nil.cjs +1 -0
- package/dist/dataParser/extended/nil.d.ts +13 -2
- package/dist/dataParser/extended/nil.mjs +1 -0
- package/dist/dataParser/extended/nullable.cjs +1 -0
- package/dist/dataParser/extended/nullable.d.ts +14 -4
- package/dist/dataParser/extended/nullable.mjs +1 -0
- package/dist/dataParser/extended/number.cjs +1 -0
- package/dist/dataParser/extended/number.d.ts +9 -2
- package/dist/dataParser/extended/number.mjs +1 -0
- package/dist/dataParser/extended/object.cjs +1 -0
- package/dist/dataParser/extended/object.d.ts +13 -2
- package/dist/dataParser/extended/object.mjs +1 -0
- package/dist/dataParser/extended/optional.cjs +1 -0
- package/dist/dataParser/extended/optional.d.ts +14 -4
- package/dist/dataParser/extended/optional.mjs +1 -0
- package/dist/dataParser/extended/pipe.cjs +1 -0
- package/dist/dataParser/extended/pipe.d.ts +13 -3
- package/dist/dataParser/extended/pipe.mjs +1 -0
- package/dist/dataParser/extended/record.cjs +3 -2
- package/dist/dataParser/extended/record.d.ts +13 -3
- package/dist/dataParser/extended/record.mjs +2 -1
- package/dist/dataParser/extended/recover.cjs +14 -0
- package/dist/dataParser/extended/recover.d.ts +23 -0
- package/dist/dataParser/extended/recover.mjs +12 -0
- package/dist/dataParser/extended/string.cjs +1 -0
- package/dist/dataParser/extended/string.d.ts +9 -2
- package/dist/dataParser/extended/string.mjs +1 -0
- package/dist/dataParser/extended/templateLiteral.cjs +4 -2
- package/dist/dataParser/extended/templateLiteral.d.ts +13 -2
- package/dist/dataParser/extended/templateLiteral.mjs +3 -1
- package/dist/dataParser/extended/transform.cjs +1 -0
- package/dist/dataParser/extended/transform.d.ts +12 -2
- package/dist/dataParser/extended/transform.mjs +1 -0
- package/dist/dataParser/extended/tuple.cjs +11 -1
- package/dist/dataParser/extended/tuple.d.ts +19 -2
- package/dist/dataParser/extended/tuple.mjs +11 -1
- package/dist/dataParser/extended/union.cjs +1 -0
- package/dist/dataParser/extended/union.d.ts +13 -2
- package/dist/dataParser/extended/union.mjs +1 -0
- package/dist/dataParser/extended/unknown.cjs +1 -0
- package/dist/dataParser/extended/unknown.d.ts +13 -2
- package/dist/dataParser/extended/unknown.mjs +1 -0
- package/dist/dataParser/identifier.cjs +2 -17
- package/dist/dataParser/identifier.d.ts +216 -8
- package/dist/dataParser/identifier.mjs +2 -17
- package/dist/dataParser/index.cjs +29 -18
- package/dist/dataParser/index.mjs +18 -14
- package/dist/dataParser/parsers/array/checkers/max.cjs +3 -3
- package/dist/dataParser/parsers/array/checkers/max.d.ts +2 -2
- package/dist/dataParser/parsers/array/checkers/max.mjs +3 -3
- package/dist/dataParser/parsers/array/checkers/min.cjs +3 -3
- package/dist/dataParser/parsers/array/checkers/min.d.ts +2 -2
- package/dist/dataParser/parsers/array/checkers/min.mjs +3 -3
- package/dist/dataParser/parsers/array/index.d.ts +14 -7
- package/dist/dataParser/parsers/bigint/checkers/max.cjs +3 -3
- package/dist/dataParser/parsers/bigint/checkers/max.d.ts +2 -2
- package/dist/dataParser/parsers/bigint/checkers/max.mjs +3 -3
- package/dist/dataParser/parsers/bigint/checkers/min.cjs +3 -3
- package/dist/dataParser/parsers/bigint/checkers/min.d.ts +2 -2
- package/dist/dataParser/parsers/bigint/checkers/min.mjs +3 -3
- package/dist/dataParser/parsers/bigint/index.d.ts +11 -4
- package/dist/dataParser/parsers/boolean.d.ts +16 -4
- package/dist/dataParser/parsers/coerce/bigint.cjs +1 -0
- package/dist/dataParser/parsers/coerce/bigint.mjs +1 -0
- package/dist/dataParser/parsers/coerce/boolean.cjs +1 -0
- package/dist/dataParser/parsers/coerce/boolean.mjs +1 -0
- package/dist/dataParser/parsers/coerce/empty.cjs +1 -0
- package/dist/dataParser/parsers/coerce/empty.mjs +1 -0
- package/dist/dataParser/parsers/coerce/nil.cjs +1 -0
- package/dist/dataParser/parsers/coerce/nil.mjs +1 -0
- package/dist/dataParser/parsers/coerce/number.cjs +1 -0
- package/dist/dataParser/parsers/coerce/number.mjs +1 -0
- package/dist/dataParser/parsers/coerce/string.cjs +1 -0
- package/dist/dataParser/parsers/coerce/string.mjs +1 -0
- package/dist/dataParser/parsers/empty.d.ts +16 -4
- package/dist/dataParser/parsers/index.d.ts +2 -0
- package/dist/dataParser/parsers/lazy.d.ts +16 -4
- package/dist/dataParser/parsers/literal.d.ts +16 -4
- package/dist/dataParser/parsers/nil.d.ts +16 -4
- package/dist/dataParser/parsers/nullable.cjs +3 -2
- package/dist/dataParser/parsers/nullable.d.ts +19 -6
- package/dist/dataParser/parsers/nullable.mjs +3 -2
- package/dist/dataParser/parsers/number/checkers/int.cjs +3 -3
- package/dist/dataParser/parsers/number/checkers/int.d.ts +2 -2
- package/dist/dataParser/parsers/number/checkers/int.mjs +3 -3
- package/dist/dataParser/parsers/number/checkers/max.cjs +3 -3
- package/dist/dataParser/parsers/number/checkers/max.d.ts +2 -2
- package/dist/dataParser/parsers/number/checkers/max.mjs +3 -3
- package/dist/dataParser/parsers/number/checkers/min.cjs +3 -3
- package/dist/dataParser/parsers/number/checkers/min.d.ts +2 -2
- package/dist/dataParser/parsers/number/checkers/min.mjs +3 -3
- package/dist/dataParser/parsers/number/index.d.ts +11 -4
- package/dist/dataParser/parsers/object.d.ts +16 -4
- package/dist/dataParser/parsers/optional.cjs +3 -2
- package/dist/dataParser/parsers/optional.d.ts +19 -6
- package/dist/dataParser/parsers/optional.mjs +3 -2
- package/dist/dataParser/parsers/pipe.d.ts +16 -4
- package/dist/dataParser/parsers/record/findRecordRequiredKey.cjs +50 -0
- package/dist/dataParser/parsers/record/findRecordRequiredKey.d.ts +4 -0
- package/dist/dataParser/parsers/record/findRecordRequiredKey.mjs +47 -0
- package/dist/dataParser/parsers/{record.cjs → record/index.cjs} +21 -3
- package/dist/dataParser/parsers/record/index.d.ts +42 -0
- package/dist/dataParser/parsers/{record.mjs → record/index.mjs} +21 -4
- package/dist/dataParser/parsers/recover.cjs +32 -0
- package/dist/dataParser/parsers/recover.d.ts +28 -0
- package/dist/dataParser/parsers/recover.mjs +29 -0
- package/dist/dataParser/parsers/refine.cjs +18 -0
- package/dist/dataParser/parsers/refine.d.ts +17 -0
- package/dist/dataParser/parsers/refine.mjs +15 -0
- package/dist/dataParser/parsers/string/checkers/email.cjs +3 -3
- package/dist/dataParser/parsers/string/checkers/email.d.ts +2 -2
- package/dist/dataParser/parsers/string/checkers/email.mjs +3 -3
- package/dist/dataParser/parsers/string/checkers/max.cjs +3 -3
- package/dist/dataParser/parsers/string/checkers/max.d.ts +2 -2
- package/dist/dataParser/parsers/string/checkers/max.mjs +3 -3
- package/dist/dataParser/parsers/string/checkers/min.cjs +3 -3
- package/dist/dataParser/parsers/string/checkers/min.d.ts +2 -2
- package/dist/dataParser/parsers/string/checkers/min.mjs +3 -3
- package/dist/dataParser/parsers/string/checkers/regex.cjs +3 -3
- package/dist/dataParser/parsers/string/checkers/regex.d.ts +2 -2
- package/dist/dataParser/parsers/string/checkers/regex.mjs +3 -3
- package/dist/dataParser/parsers/string/checkers/url.cjs +3 -3
- package/dist/dataParser/parsers/string/checkers/url.d.ts +2 -2
- package/dist/dataParser/parsers/string/checkers/url.mjs +3 -3
- package/dist/dataParser/parsers/string/index.d.ts +11 -4
- package/dist/dataParser/parsers/templateLiteral/createTemplateLiteralPattern.cjs +75 -0
- package/dist/dataParser/parsers/templateLiteral/createTemplateLiteralPattern.d.ts +2 -0
- package/dist/dataParser/parsers/templateLiteral/createTemplateLiteralPattern.mjs +73 -0
- package/dist/dataParser/parsers/templateLiteral/index.cjs +31 -0
- package/dist/dataParser/parsers/templateLiteral/index.d.ts +66 -0
- package/dist/dataParser/parsers/templateLiteral/index.mjs +27 -0
- package/dist/dataParser/parsers/transform.d.ts +16 -4
- package/dist/dataParser/parsers/tuple.d.ts +14 -4
- package/dist/dataParser/parsers/union.d.ts +16 -4
- package/dist/dataParser/parsers/unknown.d.ts +16 -4
- package/dist/dataParser/types/checkers.d.ts +1 -1
- package/dist/dataParser/types/dataParsers.d.ts +2 -2
- package/dist/either/bool/falsy.cjs +1 -1
- package/dist/either/bool/falsy.mjs +1 -1
- package/dist/either/bool/truthy.cjs +2 -2
- package/dist/either/bool/truthy.mjs +2 -2
- package/dist/either/future/create.cjs +1 -1
- package/dist/either/future/create.mjs +1 -1
- package/dist/either/nullable/empty.cjs +1 -1
- package/dist/either/nullable/empty.mjs +1 -1
- package/dist/either/nullish/filled.cjs +2 -2
- package/dist/either/nullish/filled.mjs +2 -2
- package/dist/either/optional/filled.cjs +2 -2
- package/dist/either/optional/filled.mjs +2 -2
- package/dist/either/right/asyncPipe.cjs +1 -1
- package/dist/either/right/asyncPipe.mjs +1 -1
- package/dist/either/right/pipe.cjs +1 -1
- package/dist/either/right/pipe.mjs +1 -1
- package/dist/generator/asyncReduce.cjs +1 -1
- package/dist/generator/asyncReduce.d.ts +4 -3
- package/dist/generator/asyncReduce.mjs +1 -1
- package/dist/generator/reduce.d.ts +6 -7
- package/dist/index.cjs +2 -0
- package/dist/index.mjs +1 -0
- package/dist/string/types/index.d.ts +1 -0
- package/dist/string/types/templateLiteralContainLargeType.d.ts +5 -0
- package/package.json +3 -3
- package/dist/dataParser/parsers/record.d.ts +0 -30
- package/dist/dataParser/parsers/templateLiteral.cjs +0 -47
- package/dist/dataParser/parsers/templateLiteral.d.ts +0 -49
- package/dist/dataParser/parsers/templateLiteral.mjs +0 -44
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { dataParserInit, SymbolDataParserError } from '
|
|
2
|
-
import { SymbolDataParserErrorIssue, setErrorPath, popErrorPath } from '
|
|
3
|
-
import { createDataParserKind } from '
|
|
1
|
+
import { dataParserInit, SymbolDataParserError } from '../../base.mjs';
|
|
2
|
+
import { SymbolDataParserErrorIssue, setErrorPath, popErrorPath } from '../../error.mjs';
|
|
3
|
+
import { createDataParserKind } from '../../kind.mjs';
|
|
4
|
+
import { findRecordRequiredKey } from './findRecordRequiredKey.mjs';
|
|
5
|
+
export { findRecordRequiredKeyOnTemplateLiteralPart } from './findRecordRequiredKey.mjs';
|
|
4
6
|
|
|
5
7
|
const recordKind = createDataParserKind("record");
|
|
6
8
|
function record(key, value, definition) {
|
|
@@ -10,6 +12,7 @@ function record(key, value, definition) {
|
|
|
10
12
|
checkers: definition?.checkers ?? [],
|
|
11
13
|
key,
|
|
12
14
|
value,
|
|
15
|
+
requireKey: findRecordRequiredKey(key),
|
|
13
16
|
},
|
|
14
17
|
}, {
|
|
15
18
|
sync: (data, error, self) => {
|
|
@@ -41,6 +44,13 @@ function record(key, value, definition) {
|
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
popErrorPath(error);
|
|
47
|
+
if (output === SymbolDataParserError) {
|
|
48
|
+
return output;
|
|
49
|
+
}
|
|
50
|
+
if (self.definition.requireKey
|
|
51
|
+
&& self.definition.requireKey.length !== Object.keys(output).length) {
|
|
52
|
+
return SymbolDataParserErrorIssue;
|
|
53
|
+
}
|
|
44
54
|
return output;
|
|
45
55
|
},
|
|
46
56
|
async: async (data, error, self) => {
|
|
@@ -72,9 +82,16 @@ function record(key, value, definition) {
|
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
84
|
popErrorPath(error);
|
|
85
|
+
if (output === SymbolDataParserError) {
|
|
86
|
+
return output;
|
|
87
|
+
}
|
|
88
|
+
if (self.definition.requireKey
|
|
89
|
+
&& self.definition.requireKey.length !== Object.keys(output).length) {
|
|
90
|
+
return SymbolDataParserErrorIssue;
|
|
91
|
+
}
|
|
75
92
|
return output;
|
|
76
93
|
},
|
|
77
94
|
});
|
|
78
95
|
}
|
|
79
96
|
|
|
80
|
-
export { record, recordKind };
|
|
97
|
+
export { findRecordRequiredKey, record, recordKind };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var base = require('../base.cjs');
|
|
4
|
+
var kind = require('../kind.cjs');
|
|
5
|
+
|
|
6
|
+
const recoverKind = kind.createDataParserKind("recover");
|
|
7
|
+
function recover(inner, recoveredValue, definition) {
|
|
8
|
+
return base.dataParserInit(recoverKind, {
|
|
9
|
+
definition: {
|
|
10
|
+
errorMessage: definition?.errorMessage,
|
|
11
|
+
checkers: definition?.checkers ?? [],
|
|
12
|
+
inner,
|
|
13
|
+
recoveredValue,
|
|
14
|
+
},
|
|
15
|
+
}, {
|
|
16
|
+
sync: (data, error, self) => {
|
|
17
|
+
const result = self.definition.inner.exec(data, error);
|
|
18
|
+
return result === base.SymbolDataParserError
|
|
19
|
+
? self.definition.recoveredValue
|
|
20
|
+
: result;
|
|
21
|
+
},
|
|
22
|
+
async: async (data, error, self) => {
|
|
23
|
+
const result = await self.definition.inner.asyncExec(data, error);
|
|
24
|
+
return result === base.SymbolDataParserError
|
|
25
|
+
? self.definition.recoveredValue
|
|
26
|
+
: result;
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.recover = recover;
|
|
32
|
+
exports.recoverKind = recoverKind;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type NeverCoalescing, type Kind, type FixDeepFunctionInfer } from "../../common";
|
|
2
|
+
import { type DataParserDefinition, type DataParser, type Output, type Input, type DataParserChecker } from "../base";
|
|
3
|
+
import { type AddCheckersToDefinition, type MergeDefinition } from "../../dataParser/types";
|
|
4
|
+
import { type CheckerRefineImplementation } from "./refine";
|
|
5
|
+
import { type GetPropsWithValueExtends } from "../../object";
|
|
6
|
+
export interface DataParserRecoverCheckerCustom<GenericInput extends unknown = unknown> {
|
|
7
|
+
}
|
|
8
|
+
export type DataParserRecoverCheckers<GenericInput extends unknown = unknown> = (DataParserRecoverCheckerCustom<GenericInput>[GetPropsWithValueExtends<DataParserRecoverCheckerCustom<GenericInput>, DataParserChecker>] | CheckerRefineImplementation<GenericInput>);
|
|
9
|
+
export interface DataParserDefinitionRecover extends DataParserDefinition<DataParserRecoverCheckers> {
|
|
10
|
+
readonly inner: DataParser;
|
|
11
|
+
readonly recoveredValue: unknown;
|
|
12
|
+
}
|
|
13
|
+
export declare const recoverKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsDataParser/recover", unknown>>;
|
|
14
|
+
type _DataParserRecover<GenericDefinition extends DataParserDefinitionRecover> = (DataParser<GenericDefinition, GenericDefinition["recoveredValue"], Input<GenericDefinition["inner"]>> & Kind<typeof recoverKind.definition>);
|
|
15
|
+
export interface DataParserRecover<GenericDefinition extends DataParserDefinitionRecover = DataParserDefinitionRecover> extends _DataParserRecover<GenericDefinition> {
|
|
16
|
+
addChecker<GenericChecker extends readonly [
|
|
17
|
+
DataParserRecoverCheckers<Output<this>>,
|
|
18
|
+
...DataParserRecoverCheckers<Output<this>>[]
|
|
19
|
+
]>(...args: FixDeepFunctionInfer<readonly [
|
|
20
|
+
DataParserRecoverCheckers<Output<this>>,
|
|
21
|
+
...DataParserRecoverCheckers<Output<this>>[]
|
|
22
|
+
], GenericChecker>): DataParserRecover<AddCheckersToDefinition<GenericDefinition, GenericChecker>>;
|
|
23
|
+
}
|
|
24
|
+
export declare function recover<GenericDataParser extends DataParser, GenericRecoveredValue extends unknown, const GenericDefinition extends Partial<Omit<DataParserDefinitionRecover, "inner" | "recoveredValue">> = never>(inner: GenericDataParser, recoveredValue: GenericRecoveredValue, definition?: GenericDefinition): DataParserRecover<MergeDefinition<DataParserDefinitionRecover, NeverCoalescing<GenericDefinition, {}> & {
|
|
25
|
+
inner: GenericDataParser;
|
|
26
|
+
recoveredValue: GenericRecoveredValue;
|
|
27
|
+
}>>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { dataParserInit, SymbolDataParserError } from '../base.mjs';
|
|
2
|
+
import { createDataParserKind } from '../kind.mjs';
|
|
3
|
+
|
|
4
|
+
const recoverKind = createDataParserKind("recover");
|
|
5
|
+
function recover(inner, recoveredValue, definition) {
|
|
6
|
+
return dataParserInit(recoverKind, {
|
|
7
|
+
definition: {
|
|
8
|
+
errorMessage: definition?.errorMessage,
|
|
9
|
+
checkers: definition?.checkers ?? [],
|
|
10
|
+
inner,
|
|
11
|
+
recoveredValue,
|
|
12
|
+
},
|
|
13
|
+
}, {
|
|
14
|
+
sync: (data, error, self) => {
|
|
15
|
+
const result = self.definition.inner.exec(data, error);
|
|
16
|
+
return result === SymbolDataParserError
|
|
17
|
+
? self.definition.recoveredValue
|
|
18
|
+
: result;
|
|
19
|
+
},
|
|
20
|
+
async: async (data, error, self) => {
|
|
21
|
+
const result = await self.definition.inner.asyncExec(data, error);
|
|
22
|
+
return result === SymbolDataParserError
|
|
23
|
+
? self.definition.recoveredValue
|
|
24
|
+
: result;
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { recover, recoverKind };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var base = require('../base.cjs');
|
|
4
|
+
var error = require('../error.cjs');
|
|
5
|
+
var kind = require('../kind.cjs');
|
|
6
|
+
|
|
7
|
+
const dataParserCheckerRefineKind = kind.createDataParserKind("checker-string-max");
|
|
8
|
+
function checkerRefine(theFunction, definition) {
|
|
9
|
+
return base.dataParserCheckerInit(dataParserCheckerRefineKind, {
|
|
10
|
+
definition: {
|
|
11
|
+
...definition,
|
|
12
|
+
theFunction,
|
|
13
|
+
},
|
|
14
|
+
}, (value, self) => self.definition.theFunction(value) ? value : error.SymbolDataParserErrorIssue);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.checkerRefine = checkerRefine;
|
|
18
|
+
exports.dataParserCheckerRefineKind = dataParserCheckerRefineKind;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type NeverCoalescing, type Kind } from "../../common";
|
|
2
|
+
import { type DataParserCheckerDefinition, type DataParserChecker } from "../../dataParser/base";
|
|
3
|
+
import { type AssignObjects } from "../../object";
|
|
4
|
+
export interface DataParserCheckerDefinitionRefine extends DataParserCheckerDefinition {
|
|
5
|
+
theFunction(input: unknown): boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const dataParserCheckerRefineKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsDataParser/checker-string-max", unknown>>;
|
|
8
|
+
type _DataParserCheckerRefine<GenericDefinition extends DataParserCheckerDefinitionRefine> = (Kind<typeof dataParserCheckerRefineKind.definition> & DataParserChecker<GenericDefinition, string>);
|
|
9
|
+
export interface DataParserCheckerRefine<GenericDefinition extends DataParserCheckerDefinitionRefine = DataParserCheckerDefinitionRefine> extends _DataParserCheckerRefine<GenericDefinition> {
|
|
10
|
+
}
|
|
11
|
+
export declare function checkerRefine<GenericInput extends unknown, const GenericDefinition extends Partial<Omit<DataParserCheckerDefinitionRefine, "theFunction">> = never>(theFunction: (input: GenericInput) => boolean, definition?: GenericDefinition): DataParserCheckerRefine<AssignObjects<NeverCoalescing<GenericDefinition, {}>, {
|
|
12
|
+
theFunction(input: GenericInput): boolean;
|
|
13
|
+
}>>;
|
|
14
|
+
export type CheckerRefineImplementation<GenericInput extends unknown> = DataParserCheckerRefine<AssignObjects<DataParserCheckerDefinitionRefine, {
|
|
15
|
+
theFunction(input: GenericInput): boolean;
|
|
16
|
+
}>>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { dataParserCheckerInit } from '../base.mjs';
|
|
2
|
+
import { SymbolDataParserErrorIssue } from '../error.mjs';
|
|
3
|
+
import { createDataParserKind } from '../kind.mjs';
|
|
4
|
+
|
|
5
|
+
const dataParserCheckerRefineKind = createDataParserKind("checker-string-max");
|
|
6
|
+
function checkerRefine(theFunction, definition) {
|
|
7
|
+
return dataParserCheckerInit(dataParserCheckerRefineKind, {
|
|
8
|
+
definition: {
|
|
9
|
+
...definition,
|
|
10
|
+
theFunction,
|
|
11
|
+
},
|
|
12
|
+
}, (value, self) => self.definition.theFunction(value) ? value : SymbolDataParserErrorIssue);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { checkerRefine, dataParserCheckerRefineKind };
|
|
@@ -5,10 +5,10 @@ var error = require('../../../error.cjs');
|
|
|
5
5
|
var index = require('../index.cjs');
|
|
6
6
|
var kind = require('../../../kind.cjs');
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const checkerEmailKind = kind.createDataParserKind("checker-string-email");
|
|
9
9
|
const emailPattern = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9-]*\.)+[A-Za-z]{2,}$/;
|
|
10
10
|
function checkerEmail(definition = {}) {
|
|
11
|
-
return base.dataParserCheckerInit(
|
|
11
|
+
return base.dataParserCheckerInit(checkerEmailKind, {
|
|
12
12
|
definition: {
|
|
13
13
|
...definition,
|
|
14
14
|
pattern: emailPattern,
|
|
@@ -27,5 +27,5 @@ function email(definition) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
exports.checkerEmail = checkerEmail;
|
|
30
|
-
exports.
|
|
30
|
+
exports.checkerEmailKind = checkerEmailKind;
|
|
31
31
|
exports.email = email;
|
|
@@ -4,8 +4,8 @@ export interface DataParserCheckerDefinitionEmail extends DataParserCheckerDefin
|
|
|
4
4
|
normalize?: boolean;
|
|
5
5
|
pattern: RegExp;
|
|
6
6
|
}
|
|
7
|
-
export declare const
|
|
8
|
-
type _DataParserCheckerEmail = (Kind<typeof
|
|
7
|
+
export declare const checkerEmailKind: import("../../../../common").KindHandler<import("../../../../common").KindDefinition<"@DuplojsUtilsDataParser/checker-string-email", unknown>>;
|
|
8
|
+
type _DataParserCheckerEmail = (Kind<typeof checkerEmailKind.definition> & DataParserChecker<DataParserCheckerDefinitionEmail, string>);
|
|
9
9
|
export interface DataParserCheckerEmail extends _DataParserCheckerEmail {
|
|
10
10
|
}
|
|
11
11
|
export declare function checkerEmail(definition?: Partial<DataParserCheckerDefinitionEmail>): DataParserCheckerEmail;
|
|
@@ -3,10 +3,10 @@ import { SymbolDataParserErrorIssue } from '../../../error.mjs';
|
|
|
3
3
|
import { string } from '../index.mjs';
|
|
4
4
|
import { createDataParserKind } from '../../../kind.mjs';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const checkerEmailKind = createDataParserKind("checker-string-email");
|
|
7
7
|
const emailPattern = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9-]*\.)+[A-Za-z]{2,}$/;
|
|
8
8
|
function checkerEmail(definition = {}) {
|
|
9
|
-
return dataParserCheckerInit(
|
|
9
|
+
return dataParserCheckerInit(checkerEmailKind, {
|
|
10
10
|
definition: {
|
|
11
11
|
...definition,
|
|
12
12
|
pattern: emailPattern,
|
|
@@ -24,4 +24,4 @@ function email(definition) {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
export { checkerEmail,
|
|
27
|
+
export { checkerEmail, checkerEmailKind, email };
|
|
@@ -4,9 +4,9 @@ var base = require('../../../base.cjs');
|
|
|
4
4
|
var error = require('../../../error.cjs');
|
|
5
5
|
var kind = require('../../../kind.cjs');
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const checkerStringMaxKind = kind.createDataParserKind("checker-string-max");
|
|
8
8
|
function checkerStringMax(max, definition = {}) {
|
|
9
|
-
return base.dataParserCheckerInit(
|
|
9
|
+
return base.dataParserCheckerInit(checkerStringMaxKind, {
|
|
10
10
|
definition: {
|
|
11
11
|
...definition,
|
|
12
12
|
max,
|
|
@@ -15,4 +15,4 @@ function checkerStringMax(max, definition = {}) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
exports.checkerStringMax = checkerStringMax;
|
|
18
|
-
exports.
|
|
18
|
+
exports.checkerStringMaxKind = checkerStringMaxKind;
|
|
@@ -3,8 +3,8 @@ import { type DataParserCheckerDefinition, type DataParserChecker } from "../../
|
|
|
3
3
|
export interface DataParserCheckerDefinitionStringMax extends DataParserCheckerDefinition {
|
|
4
4
|
max: number;
|
|
5
5
|
}
|
|
6
|
-
export declare const
|
|
7
|
-
type _DataParserCheckerStringMax = (Kind<typeof
|
|
6
|
+
export declare const checkerStringMaxKind: import("../../../../common").KindHandler<import("../../../../common").KindDefinition<"@DuplojsUtilsDataParser/checker-string-max", unknown>>;
|
|
7
|
+
type _DataParserCheckerStringMax = (Kind<typeof checkerStringMaxKind.definition> & DataParserChecker<DataParserCheckerDefinitionStringMax, string>);
|
|
8
8
|
export interface DataParserCheckerStringMax extends _DataParserCheckerStringMax {
|
|
9
9
|
}
|
|
10
10
|
export declare function checkerStringMax(max: number, definition?: Partial<Omit<DataParserCheckerDefinitionStringMax, "max">>): DataParserCheckerStringMax;
|
|
@@ -2,9 +2,9 @@ import { dataParserCheckerInit } from '../../../base.mjs';
|
|
|
2
2
|
import { SymbolDataParserErrorIssue } from '../../../error.mjs';
|
|
3
3
|
import { createDataParserKind } from '../../../kind.mjs';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const checkerStringMaxKind = createDataParserKind("checker-string-max");
|
|
6
6
|
function checkerStringMax(max, definition = {}) {
|
|
7
|
-
return dataParserCheckerInit(
|
|
7
|
+
return dataParserCheckerInit(checkerStringMaxKind, {
|
|
8
8
|
definition: {
|
|
9
9
|
...definition,
|
|
10
10
|
max,
|
|
@@ -12,4 +12,4 @@ function checkerStringMax(max, definition = {}) {
|
|
|
12
12
|
}, (value, self) => value.length <= self.definition.max ? value : SymbolDataParserErrorIssue);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export { checkerStringMax,
|
|
15
|
+
export { checkerStringMax, checkerStringMaxKind };
|
|
@@ -4,9 +4,9 @@ var base = require('../../../base.cjs');
|
|
|
4
4
|
var error = require('../../../error.cjs');
|
|
5
5
|
var kind = require('../../../kind.cjs');
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const checkerStringMinKind = kind.createDataParserKind("checker-string-min");
|
|
8
8
|
function checkerStringMin(min, definition = {}) {
|
|
9
|
-
return base.dataParserCheckerInit(
|
|
9
|
+
return base.dataParserCheckerInit(checkerStringMinKind, {
|
|
10
10
|
definition: {
|
|
11
11
|
...definition,
|
|
12
12
|
min,
|
|
@@ -15,4 +15,4 @@ function checkerStringMin(min, definition = {}) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
exports.checkerStringMin = checkerStringMin;
|
|
18
|
-
exports.
|
|
18
|
+
exports.checkerStringMinKind = checkerStringMinKind;
|
|
@@ -3,8 +3,8 @@ import { type DataParserCheckerDefinition, type DataParserChecker } from "../../
|
|
|
3
3
|
export interface DataParserCheckerDefinitionStringMin extends DataParserCheckerDefinition {
|
|
4
4
|
min: number;
|
|
5
5
|
}
|
|
6
|
-
export declare const
|
|
7
|
-
type _DataParserCheckerStringMin = (Kind<typeof
|
|
6
|
+
export declare const checkerStringMinKind: import("../../../../common").KindHandler<import("../../../../common").KindDefinition<"@DuplojsUtilsDataParser/checker-string-min", unknown>>;
|
|
7
|
+
type _DataParserCheckerStringMin = (Kind<typeof checkerStringMinKind.definition> & DataParserChecker<DataParserCheckerDefinitionStringMin, string>);
|
|
8
8
|
export interface DataParserCheckerStringMin extends _DataParserCheckerStringMin {
|
|
9
9
|
}
|
|
10
10
|
export declare function checkerStringMin(min: number, definition?: Partial<Omit<DataParserCheckerDefinitionStringMin, "min">>): DataParserCheckerStringMin;
|
|
@@ -2,9 +2,9 @@ import { dataParserCheckerInit } from '../../../base.mjs';
|
|
|
2
2
|
import { SymbolDataParserErrorIssue } from '../../../error.mjs';
|
|
3
3
|
import { createDataParserKind } from '../../../kind.mjs';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const checkerStringMinKind = createDataParserKind("checker-string-min");
|
|
6
6
|
function checkerStringMin(min, definition = {}) {
|
|
7
|
-
return dataParserCheckerInit(
|
|
7
|
+
return dataParserCheckerInit(checkerStringMinKind, {
|
|
8
8
|
definition: {
|
|
9
9
|
...definition,
|
|
10
10
|
min,
|
|
@@ -12,4 +12,4 @@ function checkerStringMin(min, definition = {}) {
|
|
|
12
12
|
}, (value, self) => value.length >= self.definition.min ? value : SymbolDataParserErrorIssue);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export { checkerStringMin,
|
|
15
|
+
export { checkerStringMin, checkerStringMinKind };
|
|
@@ -4,9 +4,9 @@ var base = require('../../../base.cjs');
|
|
|
4
4
|
var error = require('../../../error.cjs');
|
|
5
5
|
var kind = require('../../../kind.cjs');
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const checkerStringRegexKind = kind.createDataParserKind("checker-string-regex");
|
|
8
8
|
function checkerStringRegex(regex, definition = {}) {
|
|
9
|
-
return base.dataParserCheckerInit(
|
|
9
|
+
return base.dataParserCheckerInit(checkerStringRegexKind, {
|
|
10
10
|
definition: {
|
|
11
11
|
...definition,
|
|
12
12
|
regex,
|
|
@@ -17,4 +17,4 @@ function checkerStringRegex(regex, definition = {}) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
exports.checkerStringRegex = checkerStringRegex;
|
|
20
|
-
exports.
|
|
20
|
+
exports.checkerStringRegexKind = checkerStringRegexKind;
|
|
@@ -3,8 +3,8 @@ import { type DataParserCheckerDefinition, type DataParserChecker } from "../../
|
|
|
3
3
|
export interface DataParserCheckerDefinitionStringRegex extends DataParserCheckerDefinition {
|
|
4
4
|
regex: RegExp;
|
|
5
5
|
}
|
|
6
|
-
export declare const
|
|
7
|
-
type _DataParserCheckerStringRegex = (Kind<typeof
|
|
6
|
+
export declare const checkerStringRegexKind: import("../../../../common").KindHandler<import("../../../../common").KindDefinition<"@DuplojsUtilsDataParser/checker-string-regex", unknown>>;
|
|
7
|
+
type _DataParserCheckerStringRegex = (Kind<typeof checkerStringRegexKind.definition> & DataParserChecker<DataParserCheckerDefinitionStringRegex, string>);
|
|
8
8
|
export interface DataParserCheckerStringRegex extends _DataParserCheckerStringRegex {
|
|
9
9
|
}
|
|
10
10
|
export declare function checkerStringRegex(regex: RegExp, definition?: Partial<Omit<DataParserCheckerDefinitionStringRegex, "regex">>): DataParserCheckerStringRegex;
|
|
@@ -2,9 +2,9 @@ import { dataParserCheckerInit } from '../../../base.mjs';
|
|
|
2
2
|
import { SymbolDataParserErrorIssue } from '../../../error.mjs';
|
|
3
3
|
import { createDataParserKind } from '../../../kind.mjs';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const checkerStringRegexKind = createDataParserKind("checker-string-regex");
|
|
6
6
|
function checkerStringRegex(regex, definition = {}) {
|
|
7
|
-
return dataParserCheckerInit(
|
|
7
|
+
return dataParserCheckerInit(checkerStringRegexKind, {
|
|
8
8
|
definition: {
|
|
9
9
|
...definition,
|
|
10
10
|
regex,
|
|
@@ -14,4 +14,4 @@ function checkerStringRegex(regex, definition = {}) {
|
|
|
14
14
|
: SymbolDataParserErrorIssue);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export { checkerStringRegex,
|
|
17
|
+
export { checkerStringRegex, checkerStringRegexKind };
|
|
@@ -5,10 +5,10 @@ var error = require('../../../error.cjs');
|
|
|
5
5
|
var index = require('../index.cjs');
|
|
6
6
|
var kind = require('../../../kind.cjs');
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const checkerUrlKind = kind.createDataParserKind("checker-string-url");
|
|
9
9
|
const regexRemoveDote = /:$/;
|
|
10
10
|
function checkerUrl(definition = {}) {
|
|
11
|
-
return base.dataParserCheckerInit(
|
|
11
|
+
return base.dataParserCheckerInit(checkerUrlKind, {
|
|
12
12
|
definition: definition,
|
|
13
13
|
}, (input, self) => {
|
|
14
14
|
try {
|
|
@@ -44,5 +44,5 @@ function url(definition) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
exports.checkerUrl = checkerUrl;
|
|
47
|
-
exports.
|
|
47
|
+
exports.checkerUrlKind = checkerUrlKind;
|
|
48
48
|
exports.url = url;
|
|
@@ -5,8 +5,8 @@ export interface DataParserCheckerDefinitionUrl extends DataParserCheckerDefinit
|
|
|
5
5
|
protocol?: RegExp;
|
|
6
6
|
normalize?: boolean;
|
|
7
7
|
}
|
|
8
|
-
export declare const
|
|
9
|
-
type _DataParserCheckerUrl = (Kind<typeof
|
|
8
|
+
export declare const checkerUrlKind: import("../../../../common").KindHandler<import("../../../../common").KindDefinition<"@DuplojsUtilsDataParser/checker-string-url", unknown>>;
|
|
9
|
+
type _DataParserCheckerUrl = (Kind<typeof checkerUrlKind.definition> & DataParserChecker<DataParserCheckerDefinitionUrl, string>);
|
|
10
10
|
export interface DataParserCheckerUrl extends _DataParserCheckerUrl {
|
|
11
11
|
}
|
|
12
12
|
export declare function checkerUrl(definition?: Partial<DataParserCheckerDefinitionUrl>): DataParserCheckerUrl;
|
|
@@ -3,10 +3,10 @@ import { SymbolDataParserErrorIssue } from '../../../error.mjs';
|
|
|
3
3
|
import { string } from '../index.mjs';
|
|
4
4
|
import { createDataParserKind } from '../../../kind.mjs';
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const checkerUrlKind = createDataParserKind("checker-string-url");
|
|
7
7
|
const regexRemoveDote = /:$/;
|
|
8
8
|
function checkerUrl(definition = {}) {
|
|
9
|
-
return dataParserCheckerInit(
|
|
9
|
+
return dataParserCheckerInit(checkerUrlKind, {
|
|
10
10
|
definition: definition,
|
|
11
11
|
}, (input, self) => {
|
|
12
12
|
try {
|
|
@@ -41,4 +41,4 @@ function url(definition) {
|
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
export { checkerUrl,
|
|
44
|
+
export { checkerUrl, checkerUrlKind, url };
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import { type NeverCoalescing, type Kind } from "../../../common";
|
|
2
|
-
import { type DataParserDefinition, type DataParser } from "../../base";
|
|
1
|
+
import { type NeverCoalescing, type Kind, type FixDeepFunctionInfer } from "../../../common";
|
|
2
|
+
import { type DataParserDefinition, type DataParser, type DataParserChecker } from "../../base";
|
|
3
3
|
import { type AddCheckersToDefinition, type MergeDefinition } from "../../../dataParser/types";
|
|
4
4
|
import { type DataParserCheckerUrl, type DataParserCheckerEmail, type DataParserCheckerStringMin, type DataParserCheckerStringMax, type DataParserCheckerStringRegex } from "./checkers";
|
|
5
|
+
import { type CheckerRefineImplementation } from "../refine";
|
|
6
|
+
import { type GetPropsWithValueExtends } from "../../../object";
|
|
5
7
|
export * from "./checkers";
|
|
6
|
-
export
|
|
8
|
+
export interface DataParserStringCheckerCustom {
|
|
9
|
+
}
|
|
10
|
+
export type DataParserStringCheckers = (DataParserStringCheckerCustom[GetPropsWithValueExtends<DataParserStringCheckerCustom, DataParserChecker>] | DataParserCheckerUrl | DataParserCheckerEmail | DataParserCheckerStringMin | DataParserCheckerStringMax | DataParserCheckerStringRegex | CheckerRefineImplementation<string>);
|
|
7
11
|
export interface DataParserDefinitionString extends DataParserDefinition<DataParserStringCheckers> {
|
|
8
12
|
readonly coerce: boolean;
|
|
9
13
|
}
|
|
@@ -13,6 +17,9 @@ export interface DataParserString<GenericDefinition extends DataParserDefinition
|
|
|
13
17
|
addChecker<GenericChecker extends readonly [
|
|
14
18
|
DataParserStringCheckers,
|
|
15
19
|
...DataParserStringCheckers[]
|
|
16
|
-
]>(...args:
|
|
20
|
+
]>(...args: FixDeepFunctionInfer<readonly [
|
|
21
|
+
DataParserStringCheckers,
|
|
22
|
+
...DataParserStringCheckers[]
|
|
23
|
+
], GenericChecker>): DataParserString<AddCheckersToDefinition<GenericDefinition, GenericChecker>>;
|
|
17
24
|
}
|
|
18
25
|
export declare function string<const GenericDefinition extends Partial<DataParserDefinitionString> = never>(definition?: GenericDefinition): DataParserString<MergeDefinition<DataParserDefinitionString, NeverCoalescing<GenericDefinition, {}>>>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var escapeRegExp = require('../../../common/escapeRegExp.cjs');
|
|
4
|
+
var pipe = require('../../../common/pipe.cjs');
|
|
5
|
+
var innerPipe = require('../../../common/innerPipe.cjs');
|
|
6
|
+
var when$1 = require('../../../common/when.cjs');
|
|
7
|
+
var isType = require('../../../common/isType.cjs');
|
|
8
|
+
var or = require('../../../common/or.cjs');
|
|
9
|
+
var justReturn = require('../../../common/justReturn.cjs');
|
|
10
|
+
var find = require('../../../array/find.cjs');
|
|
11
|
+
var to = require('../../../object/to.cjs');
|
|
12
|
+
var map = require('../../../array/map.cjs');
|
|
13
|
+
var join = require('../../../array/join.cjs');
|
|
14
|
+
require('../../../common/globalStore.cjs');
|
|
15
|
+
require('../../../common/builder.cjs');
|
|
16
|
+
var index = require('./index.cjs');
|
|
17
|
+
require('../../../pattern/result.cjs');
|
|
18
|
+
var exhaustive = require('../../../pattern/exhaustive.cjs');
|
|
19
|
+
var when = require('../../../pattern/when.cjs');
|
|
20
|
+
var replace = require('../../../string/replace.cjs');
|
|
21
|
+
var index$3 = require('../number/index.cjs');
|
|
22
|
+
var index$2 = require('../bigint/index.cjs');
|
|
23
|
+
var boolean = require('../boolean.cjs');
|
|
24
|
+
var nil = require('../nil.cjs');
|
|
25
|
+
var empty = require('../empty.cjs');
|
|
26
|
+
var literal = require('../literal.cjs');
|
|
27
|
+
var index$1 = require('../string/index.cjs');
|
|
28
|
+
var union = require('../union.cjs');
|
|
29
|
+
var regex = require('../string/checkers/regex.cjs');
|
|
30
|
+
var max = require('../string/checkers/max.cjs');
|
|
31
|
+
var min = require('../string/checkers/min.cjs');
|
|
32
|
+
var email = require('../string/checkers/email.cjs');
|
|
33
|
+
var int = require('../number/checkers/int.cjs');
|
|
34
|
+
|
|
35
|
+
function createTemplateLiteralPattern(templatePart) {
|
|
36
|
+
return pipe.pipe(templatePart, map.map(innerPipe.innerPipe(when.when(or.or([
|
|
37
|
+
isType.isType("string"),
|
|
38
|
+
isType.isType("boolean"),
|
|
39
|
+
isType.isType("bigint"),
|
|
40
|
+
isType.isType("null"),
|
|
41
|
+
isType.isType("undefined"),
|
|
42
|
+
isType.isType("number"),
|
|
43
|
+
]), innerPipe.innerPipe(when$1.when(isType.isType("bigint"), (value) => `${value}n`), String, escapeRegExp.escapeRegExp, (value) => `(?:${value})`)), when.when(index$3.numberKind.has, (dataParser) => pipe.pipe(dataParser.definition.checkers, to.to({
|
|
44
|
+
int: innerPipe.innerPipe(find.find(int.checkerIntKind.has), when$1.when(int.checkerIntKind.has, justReturn.justReturn(true))),
|
|
45
|
+
}), ({ int }) => {
|
|
46
|
+
if (int) {
|
|
47
|
+
return "(?:[0-9]+)";
|
|
48
|
+
}
|
|
49
|
+
return "(?:[0-9]+(\\.[0-9]+)?)";
|
|
50
|
+
})), when.when(index$2.bigIntKind.has, () => "(?:[0-9]+n)"), when.when(boolean.booleanKind.has, () => "(?:true|false)"), when.when(nil.nilKind.has, () => "(?:null)"), when.when(empty.emptyKind.has, () => "(?:undefined)"), when.when(literal.literalKind.has, (dataParser) => pipe.pipe(dataParser.definition.value, map.map((element) => createTemplateLiteralPattern([element])), join.join("|"), (pattern) => `(?:${pattern})`)), when.when(index$1.stringKind.has, (dataParser) => pipe.pipe(dataParser.definition.checkers, to.to({
|
|
51
|
+
email: innerPipe.innerPipe(find.find(email.checkerEmailKind.has), when$1.when(email.checkerEmailKind.has, (checker) => pipe.pipe(checker.definition.pattern.source, replace.replace(/^\^/, ""), replace.replace(/\$$/, "")))),
|
|
52
|
+
min: innerPipe.innerPipe(find.find(min.checkerStringMinKind.has), when$1.when(min.checkerStringMinKind.has, (checker) => checker.definition.min)),
|
|
53
|
+
max: innerPipe.innerPipe(find.find(max.checkerStringMaxKind.has), when$1.when(max.checkerStringMaxKind.has, (checker) => checker.definition.max)),
|
|
54
|
+
regex: innerPipe.innerPipe(find.find(regex.checkerStringRegexKind.has), when$1.when(regex.checkerStringRegexKind.has, (checker) => pipe.pipe(checker.definition.regex.source, replace.replace(/^\^/, ""), replace.replace(/\$$/, "")))),
|
|
55
|
+
}), ({ email, regex, max, min }) => {
|
|
56
|
+
if (email) {
|
|
57
|
+
return email;
|
|
58
|
+
}
|
|
59
|
+
else if (regex) {
|
|
60
|
+
return regex;
|
|
61
|
+
}
|
|
62
|
+
else if (max !== undefined && min !== undefined) {
|
|
63
|
+
return `(?:[^]{${min},${max}})`;
|
|
64
|
+
}
|
|
65
|
+
else if (max !== undefined) {
|
|
66
|
+
return `(?:[^]{0,${max}})`;
|
|
67
|
+
}
|
|
68
|
+
else if (min !== undefined) {
|
|
69
|
+
return `(?:[^]{${min},})`;
|
|
70
|
+
}
|
|
71
|
+
return "(?:[^]*)";
|
|
72
|
+
})), innerPipe.innerPipe(when.when(index.templateLiteralKind.has, (dataParser) => pipe.pipe(dataParser.definition.pattern.source, replace.replace(/^\^/, ""), replace.replace(/\$$/, ""), (pattern) => `(?:${pattern})`)), when.when(union.unionKind.has, (dataParser) => pipe.pipe(dataParser.definition.options, map.map((option) => createTemplateLiteralPattern([option])), join.join("|"), (pattern) => `(?:${pattern})`)), exhaustive.exhaustive))), join.join(""));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
exports.createTemplateLiteralPattern = createTemplateLiteralPattern;
|