typia 3.4.22 → 3.4.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +57 -23
  2. package/lib/programmers/AssertProgrammer.js +79 -70
  3. package/lib/programmers/AssertProgrammer.js.map +1 -1
  4. package/lib/programmers/IsProgrammer.d.ts +1 -0
  5. package/lib/programmers/IsProgrammer.js +4 -0
  6. package/lib/programmers/IsProgrammer.js.map +1 -1
  7. package/lib/programmers/ValidateProgrammer.js +68 -59
  8. package/lib/programmers/ValidateProgrammer.js.map +1 -1
  9. package/lib/programmers/helpers/OptionPredicator.d.ts +1 -0
  10. package/lib/programmers/helpers/OptionPredicator.js +4 -0
  11. package/lib/programmers/helpers/OptionPredicator.js.map +1 -1
  12. package/lib/programmers/internal/check_dynamic_properties.js +5 -0
  13. package/lib/programmers/internal/check_dynamic_properties.js.map +1 -1
  14. package/lib/programmers/internal/check_object.d.ts +1 -0
  15. package/lib/programmers/internal/check_object.js.map +1 -1
  16. package/lib/transformers/ITransformOptions.d.ts +10 -0
  17. package/package.json +2 -2
  18. package/src/IValidation.ts +21 -21
  19. package/src/Primitive.ts +82 -82
  20. package/src/TypeGuardError.ts +36 -36
  21. package/src/executable/internal/CommandParser.ts +15 -15
  22. package/src/factories/CommentFactory.ts +10 -10
  23. package/src/factories/ExpressionFactory.ts +66 -66
  24. package/src/factories/IdentifierFactory.ts +72 -72
  25. package/src/factories/LiteralFactory.ts +44 -44
  26. package/src/factories/StatementFactory.ts +60 -60
  27. package/src/factories/TemplateFactory.ts +56 -56
  28. package/src/factories/TypeFactory.ts +101 -101
  29. package/src/factories/ValueFactory.ts +12 -12
  30. package/src/functional/$every.ts +11 -11
  31. package/src/functional/$is_email.ts +5 -5
  32. package/src/functional/$is_ipv4.ts +5 -5
  33. package/src/functional/$is_ipv6.ts +5 -5
  34. package/src/functional/$is_url.ts +5 -5
  35. package/src/functional/$is_uuid.ts +5 -5
  36. package/src/functional/$join.ts +50 -50
  37. package/src/functional/$report.ts +15 -15
  38. package/src/functional/$rest.ts +3 -3
  39. package/src/functional/$string.ts +37 -37
  40. package/src/functional/$tail.ts +6 -6
  41. package/src/index.ts +4 -4
  42. package/src/metadata/IJsDocTagInfo.ts +10 -10
  43. package/src/metadata/IMetadata.ts +25 -25
  44. package/src/metadata/IMetadataApplication.ts +7 -7
  45. package/src/metadata/IMetadataConstant.ts +16 -16
  46. package/src/metadata/IMetadataEntry.ts +6 -6
  47. package/src/metadata/IMetadataObject.ts +29 -29
  48. package/src/metadata/IMetadataProperty.ts +11 -11
  49. package/src/metadata/MetadataConstant.ts +3 -3
  50. package/src/metadata/MetadataObject.ts +131 -131
  51. package/src/metadata/MetadataProperty.ts +64 -64
  52. package/src/programmers/ApplicationProgrammer.ts +55 -55
  53. package/src/programmers/AssertProgrammer.ts +36 -29
  54. package/src/programmers/IsProgrammer.ts +5 -0
  55. package/src/programmers/ValidateProgrammer.ts +36 -29
  56. package/src/programmers/helpers/AtomicPredicator.ts +15 -15
  57. package/src/programmers/helpers/FunctionImporeter.ts +31 -31
  58. package/src/programmers/helpers/IExpressionEntry.ts +10 -10
  59. package/src/programmers/helpers/OptionPredicator.ts +4 -0
  60. package/src/programmers/helpers/StringifyJoinder.ts +111 -111
  61. package/src/programmers/helpers/StringifyPredicator.ts +18 -18
  62. package/src/programmers/helpers/UnionPredicator.ts +81 -81
  63. package/src/programmers/internal/application_array.ts +47 -47
  64. package/src/programmers/internal/application_boolean.ts +17 -17
  65. package/src/programmers/internal/application_constant.ts +29 -29
  66. package/src/programmers/internal/application_default_string.ts +32 -32
  67. package/src/programmers/internal/application_native.ts +29 -29
  68. package/src/programmers/internal/application_number.ts +76 -76
  69. package/src/programmers/internal/application_string.ts +49 -49
  70. package/src/programmers/internal/application_templates.ts +27 -27
  71. package/src/programmers/internal/application_tuple.ts +29 -29
  72. package/src/programmers/internal/check_dynamic_properties.ts +164 -146
  73. package/src/programmers/internal/check_everything.ts +25 -25
  74. package/src/programmers/internal/check_length.ts +46 -46
  75. package/src/programmers/internal/check_native.ts +9 -9
  76. package/src/programmers/internal/check_object.ts +43 -42
  77. package/src/programmers/internal/check_string.ts +24 -24
  78. package/src/programmers/internal/check_string_tags.ts +63 -63
  79. package/src/programmers/internal/check_template.ts +50 -50
  80. package/src/programmers/internal/decode_union_object.ts +73 -73
  81. package/src/programmers/internal/feature_object_entries.ts +49 -49
  82. package/src/programmers/internal/metadata_to_pattern.ts +31 -31
  83. package/src/programmers/internal/stringify_dynamic_properties.ts +164 -164
  84. package/src/programmers/internal/stringify_native.ts +8 -8
  85. package/src/programmers/internal/stringify_regular_properties.ts +81 -81
  86. package/src/programmers/internal/template_to_pattern.ts +15 -15
  87. package/src/schemas/IJsonApplication.ts +9 -9
  88. package/src/schemas/IJsonComponents.ts +26 -26
  89. package/src/transform.ts +20 -20
  90. package/src/transformers/ExpressionWithArgumentTransformer.ts +66 -66
  91. package/src/transformers/FileTransformer.ts +49 -49
  92. package/src/transformers/IProject.ts +11 -11
  93. package/src/transformers/ITransformOptions.ts +11 -0
  94. package/src/transformers/NodeTransformer.ts +19 -19
  95. package/src/transformers/features/miscellaneous/MetadataTransformer.ts +55 -55
  96. package/src/transformers/features/parsers/AssertParseTransformer.ts +36 -36
  97. package/src/transformers/features/parsers/CreateAssertParseTransformer.ts +32 -32
  98. package/src/transformers/features/parsers/CreateIsParseTransformer.ts +32 -32
  99. package/src/transformers/features/parsers/CreateValidateParseTransformer.ts +32 -32
  100. package/src/transformers/features/parsers/IsParseTransformer.ts +36 -36
  101. package/src/transformers/features/parsers/ValidateParseTransformer.ts +36 -36
  102. package/src/transformers/features/stringifiers/AssertStringifyTransformer.ts +38 -38
  103. package/src/transformers/features/stringifiers/CreateAssertStringifyTransformer.ts +32 -32
  104. package/src/transformers/features/stringifiers/CreateIsStringifyTransformer.ts +32 -32
  105. package/src/transformers/features/stringifiers/CreateStringifyTransformer.ts +31 -31
  106. package/src/transformers/features/stringifiers/CreateValidateStringifyProgrammer.ts +32 -32
  107. package/src/transformers/features/stringifiers/IsStringifyTransformer.ts +38 -38
  108. package/src/transformers/features/stringifiers/ValidateStringifyTransformer.ts +38 -38
  109. package/src/transformers/features/validators/AssertTransformer.ts +43 -43
  110. package/src/transformers/features/validators/CreateAssertTransformer.ts +35 -35
  111. package/src/transformers/features/validators/CreateIsTransformer.ts +35 -35
  112. package/src/transformers/features/validators/CreateValidateTransformer.ts +35 -35
  113. package/src/transformers/features/validators/IsTransformer.ts +43 -43
  114. package/src/transformers/features/validators/ValidateTransformer.ts +43 -43
  115. package/src/typings/Atomic.ts +17 -17
  116. package/src/typings/ClassProperties.ts +5 -5
  117. package/src/typings/OmitNever.ts +3 -3
  118. package/src/typings/SpecialFields.ts +3 -3
  119. package/src/typings/Writable.ts +11 -11
  120. package/src/utils/ArrayUtil.ts +49 -49
  121. package/src/utils/Escaper.ts +50 -50
  122. package/src/utils/MapUtil.ts +14 -14
  123. package/src/utils/PatternUtil.ts +30 -30
  124. package/src/utils/Singleton.ts +17 -17
@@ -1,29 +1,29 @@
1
- import { Metadata } from "../../metadata/Metadata";
2
- import { IJsonComponents } from "../../schemas/IJsonComponents";
3
- import { IJsonSchema } from "../../schemas/IJsonSchema";
4
-
5
- import { ApplicationProgrammer } from "../ApplicationProgrammer";
6
- import { application_schema } from "./application_schema";
7
-
8
- /**
9
- * @internal
10
- */
11
- export const application_tuple =
12
- (options: ApplicationProgrammer.IOptions) =>
13
- (components: IJsonComponents) =>
14
- (
15
- items: Array<Metadata>,
16
- nullable: boolean,
17
- attribute: IJsonSchema.IAttribute,
18
- ): IJsonSchema.ITuple => ({
19
- type: "array",
20
- items: items.map((meta, i) =>
21
- application_schema(options)(components)(false)(meta.rest ?? meta, {
22
- ...attribute,
23
- "x-typia-rest":
24
- i === items.length - 1 ? meta.rest !== null : undefined,
25
- }),
26
- ),
27
- nullable,
28
- ...attribute,
29
- });
1
+ import { Metadata } from "../../metadata/Metadata";
2
+ import { IJsonComponents } from "../../schemas/IJsonComponents";
3
+ import { IJsonSchema } from "../../schemas/IJsonSchema";
4
+
5
+ import { ApplicationProgrammer } from "../ApplicationProgrammer";
6
+ import { application_schema } from "./application_schema";
7
+
8
+ /**
9
+ * @internal
10
+ */
11
+ export const application_tuple =
12
+ (options: ApplicationProgrammer.IOptions) =>
13
+ (components: IJsonComponents) =>
14
+ (
15
+ items: Array<Metadata>,
16
+ nullable: boolean,
17
+ attribute: IJsonSchema.IAttribute,
18
+ ): IJsonSchema.ITuple => ({
19
+ type: "array",
20
+ items: items.map((meta, i) =>
21
+ application_schema(options)(components)(false)(meta.rest ?? meta, {
22
+ ...attribute,
23
+ "x-typia-rest":
24
+ i === items.length - 1 ? meta.rest !== null : undefined,
25
+ }),
26
+ ),
27
+ nullable,
28
+ ...attribute,
29
+ });
@@ -1,146 +1,164 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
- import { StatementFactory } from "../../factories/StatementFactory";
5
-
6
- import { IExpressionEntry } from "../helpers/IExpressionEntry";
7
- import { check_everything } from "./check_everything";
8
- import { check_object } from "./check_object";
9
- import { metadata_to_pattern } from "./metadata_to_pattern";
10
-
11
- /**
12
- * @internal
13
- */
14
- export const check_dynamic_properties =
15
- (props: check_object.IProps) =>
16
- (
17
- regular: IExpressionEntry[],
18
- dynamic: IExpressionEntry[],
19
- ): ts.Expression => {
20
- const criteria = props.entries
21
- ? ts.factory.createCallExpression(props.entries, undefined, [
22
- ts.factory.createCallExpression(
23
- ts.factory.createIdentifier("Object.keys"),
24
- undefined,
25
- [ts.factory.createIdentifier("input")],
26
- ),
27
- check_dynamic_property(props)(regular, dynamic),
28
- ])
29
- : ts.factory.createCallExpression(
30
- IdentifierFactory.join(
31
- ts.factory.createCallExpression(
32
- ts.factory.createIdentifier("Object.keys"),
33
- undefined,
34
- [ts.factory.createIdentifier("input")],
35
- ),
36
- props.assert ? "every" : "map",
37
- ),
38
- undefined,
39
- [check_dynamic_property(props)(regular, dynamic)],
40
- );
41
- return (props.halt || ((elem) => elem))(
42
- props.assert ? criteria : check_everything(criteria),
43
- );
44
- };
45
-
46
- const check_dynamic_property =
47
- (props: check_object.IProps) =>
48
- (regular: IExpressionEntry[], dynamic: IExpressionEntry[]) => {
49
- //----
50
- // IF CONDITIONS
51
- //----
52
- // PREPARE ASSETS
53
- const key = ts.factory.createIdentifier("key");
54
- const value = ts.factory.createIdentifier("value");
55
-
56
- const statements: ts.Statement[] = [];
57
- const add = (exp: ts.Expression, output: ts.Expression) =>
58
- statements.push(
59
- ts.factory.createIfStatement(
60
- exp,
61
- ts.factory.createReturnStatement(output),
62
- ),
63
- );
64
-
65
- // GATHER CONDITIONS
66
- if (props.equals === true && regular.length)
67
- add(is_regular_property(regular), props.positive);
68
- statements.push(
69
- StatementFactory.constant(
70
- "value",
71
- ts.factory.createIdentifier("input[key]"),
72
- ),
73
- );
74
- add(
75
- ts.factory.createStrictEquality(
76
- ts.factory.createIdentifier("undefined"),
77
- value,
78
- ),
79
- props.positive,
80
- );
81
- for (const entry of dynamic)
82
- add(
83
- ts.factory.createCallExpression(
84
- ts.factory.createIdentifier(
85
- `RegExp(/${metadata_to_pattern(true)(
86
- entry.key,
87
- )}/).test`,
88
- ),
89
- undefined,
90
- [key],
91
- ),
92
- entry.expression,
93
- );
94
-
95
- //----
96
- // FUNCTION BODY
97
- //----
98
- // CLOSURE BLOCK
99
- const block: ts.Block = ts.factory.createBlock(
100
- [
101
- ...statements,
102
- ts.factory.createReturnStatement(
103
- props.equals === true
104
- ? props.superfluous(value)
105
- : props.positive,
106
- ),
107
- ],
108
- true,
109
- );
110
-
111
- // RETURNS
112
- return ts.factory.createArrowFunction(
113
- undefined,
114
- undefined,
115
- [IdentifierFactory.parameter("key")],
116
- undefined,
117
- undefined,
118
- block,
119
- );
120
- };
121
-
122
- const is_regular_property = (regular: IExpressionEntry[]) =>
123
- ts.factory.createCallExpression(
124
- IdentifierFactory.join(
125
- ts.factory.createArrayLiteralExpression(
126
- regular.map((entry) =>
127
- ts.factory.createStringLiteral(entry.key.getSoleLiteral()!),
128
- ),
129
- ),
130
- "some",
131
- ),
132
- undefined,
133
- [
134
- ts.factory.createArrowFunction(
135
- undefined,
136
- undefined,
137
- [IdentifierFactory.parameter("prop")],
138
- undefined,
139
- undefined,
140
- ts.factory.createStrictEquality(
141
- ts.factory.createIdentifier("key"),
142
- ts.factory.createIdentifier("prop"),
143
- ),
144
- ),
145
- ],
146
- );
1
+ import ts from "typescript";
2
+
3
+ import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
+ import { StatementFactory } from "../../factories/StatementFactory";
5
+
6
+ import { IExpressionEntry } from "../helpers/IExpressionEntry";
7
+ import { check_everything } from "./check_everything";
8
+ import { check_object } from "./check_object";
9
+ import { metadata_to_pattern } from "./metadata_to_pattern";
10
+
11
+ /**
12
+ * @internal
13
+ */
14
+ export const check_dynamic_properties =
15
+ (props: check_object.IProps) =>
16
+ (
17
+ regular: IExpressionEntry[],
18
+ dynamic: IExpressionEntry[],
19
+ ): ts.Expression => {
20
+ if (
21
+ props.equals === true &&
22
+ props.undefined === false &&
23
+ regular.every((r) => r.meta.required) &&
24
+ dynamic.length === 0
25
+ )
26
+ return ts.factory.createStrictEquality(
27
+ ts.factory.createNumericLiteral(regular.length),
28
+ IdentifierFactory.join(
29
+ ts.factory.createCallExpression(
30
+ ts.factory.createIdentifier("Object.keys"),
31
+ undefined,
32
+ [ts.factory.createIdentifier("input")],
33
+ ),
34
+ "length",
35
+ ),
36
+ );
37
+
38
+ const criteria = props.entries
39
+ ? ts.factory.createCallExpression(props.entries, undefined, [
40
+ ts.factory.createCallExpression(
41
+ ts.factory.createIdentifier("Object.keys"),
42
+ undefined,
43
+ [ts.factory.createIdentifier("input")],
44
+ ),
45
+ check_dynamic_property(props)(regular, dynamic),
46
+ ])
47
+ : ts.factory.createCallExpression(
48
+ IdentifierFactory.join(
49
+ ts.factory.createCallExpression(
50
+ ts.factory.createIdentifier("Object.keys"),
51
+ undefined,
52
+ [ts.factory.createIdentifier("input")],
53
+ ),
54
+ props.assert ? "every" : "map",
55
+ ),
56
+ undefined,
57
+ [check_dynamic_property(props)(regular, dynamic)],
58
+ );
59
+ return (props.halt || ((elem) => elem))(
60
+ props.assert ? criteria : check_everything(criteria),
61
+ );
62
+ };
63
+
64
+ const check_dynamic_property =
65
+ (props: check_object.IProps) =>
66
+ (regular: IExpressionEntry[], dynamic: IExpressionEntry[]) => {
67
+ //----
68
+ // IF CONDITIONS
69
+ //----
70
+ // PREPARE ASSETS
71
+ const key = ts.factory.createIdentifier("key");
72
+ const value = ts.factory.createIdentifier("value");
73
+
74
+ const statements: ts.Statement[] = [];
75
+ const add = (exp: ts.Expression, output: ts.Expression) =>
76
+ statements.push(
77
+ ts.factory.createIfStatement(
78
+ exp,
79
+ ts.factory.createReturnStatement(output),
80
+ ),
81
+ );
82
+
83
+ // GATHER CONDITIONS
84
+ if (props.equals === true && regular.length)
85
+ add(is_regular_property(regular), props.positive);
86
+ statements.push(
87
+ StatementFactory.constant(
88
+ "value",
89
+ ts.factory.createIdentifier("input[key]"),
90
+ ),
91
+ );
92
+ add(
93
+ ts.factory.createStrictEquality(
94
+ ts.factory.createIdentifier("undefined"),
95
+ value,
96
+ ),
97
+ props.positive,
98
+ );
99
+ for (const entry of dynamic)
100
+ add(
101
+ ts.factory.createCallExpression(
102
+ ts.factory.createIdentifier(
103
+ `RegExp(/${metadata_to_pattern(true)(
104
+ entry.key,
105
+ )}/).test`,
106
+ ),
107
+ undefined,
108
+ [key],
109
+ ),
110
+ entry.expression,
111
+ );
112
+
113
+ //----
114
+ // FUNCTION BODY
115
+ //----
116
+ // CLOSURE BLOCK
117
+ const block: ts.Block = ts.factory.createBlock(
118
+ [
119
+ ...statements,
120
+ ts.factory.createReturnStatement(
121
+ props.equals === true
122
+ ? props.superfluous(value)
123
+ : props.positive,
124
+ ),
125
+ ],
126
+ true,
127
+ );
128
+
129
+ // RETURNS
130
+ return ts.factory.createArrowFunction(
131
+ undefined,
132
+ undefined,
133
+ [IdentifierFactory.parameter("key")],
134
+ undefined,
135
+ undefined,
136
+ block,
137
+ );
138
+ };
139
+
140
+ const is_regular_property = (regular: IExpressionEntry[]) =>
141
+ ts.factory.createCallExpression(
142
+ IdentifierFactory.join(
143
+ ts.factory.createArrayLiteralExpression(
144
+ regular.map((entry) =>
145
+ ts.factory.createStringLiteral(entry.key.getSoleLiteral()!),
146
+ ),
147
+ ),
148
+ "some",
149
+ ),
150
+ undefined,
151
+ [
152
+ ts.factory.createArrowFunction(
153
+ undefined,
154
+ undefined,
155
+ [IdentifierFactory.parameter("prop")],
156
+ undefined,
157
+ undefined,
158
+ ts.factory.createStrictEquality(
159
+ ts.factory.createIdentifier("key"),
160
+ ts.factory.createIdentifier("prop"),
161
+ ),
162
+ ),
163
+ ],
164
+ );
@@ -1,25 +1,25 @@
1
- import ts from "typescript";
2
-
3
- import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
-
5
- /**
6
- * @internal
7
- */
8
- export const check_everything = (array: ts.Expression) =>
9
- ts.factory.createCallExpression(
10
- IdentifierFactory.join(array, "every"),
11
- undefined,
12
- [
13
- ts.factory.createArrowFunction(
14
- undefined,
15
- undefined,
16
- [IdentifierFactory.parameter("flag")],
17
- undefined,
18
- undefined,
19
- ts.factory.createStrictEquality(
20
- ts.factory.createTrue(),
21
- ts.factory.createIdentifier("flag"),
22
- ),
23
- ),
24
- ],
25
- );
1
+ import ts from "typescript";
2
+
3
+ import { IdentifierFactory } from "../../factories/IdentifierFactory";
4
+
5
+ /**
6
+ * @internal
7
+ */
8
+ export const check_everything = (array: ts.Expression) =>
9
+ ts.factory.createCallExpression(
10
+ IdentifierFactory.join(array, "every"),
11
+ undefined,
12
+ [
13
+ ts.factory.createArrowFunction(
14
+ undefined,
15
+ undefined,
16
+ [IdentifierFactory.parameter("flag")],
17
+ undefined,
18
+ undefined,
19
+ ts.factory.createStrictEquality(
20
+ ts.factory.createTrue(),
21
+ ts.factory.createIdentifier("flag"),
22
+ ),
23
+ ),
24
+ ],
25
+ );
@@ -1,46 +1,46 @@
1
- import ts from "typescript";
2
-
3
- import { IMetadataTag } from "../../metadata/IMetadataTag";
4
-
5
- /**
6
- * @internal
7
- */
8
- export function check_length(
9
- conditions: ts.Expression[],
10
- length: ts.Expression,
11
- tag: Omit<IMetadataTag.ILength, "kind">,
12
- ) {
13
- if (
14
- tag.minimum !== undefined &&
15
- tag.maximum !== undefined &&
16
- tag.minimum.value === tag.maximum.value &&
17
- tag.minimum.include === true &&
18
- tag.maximum.include === true
19
- ) {
20
- conditions.push(
21
- ts.factory.createStrictEquality(
22
- ts.factory.createNumericLiteral(tag.minimum.value),
23
- length,
24
- ),
25
- );
26
- } else {
27
- if (tag.minimum !== undefined)
28
- conditions.push(
29
- (tag.minimum.include
30
- ? ts.factory.createLessThanEquals
31
- : ts.factory.createLessThan)(
32
- ts.factory.createNumericLiteral(tag.minimum.value),
33
- length,
34
- ),
35
- );
36
- if (tag.maximum !== undefined)
37
- conditions.push(
38
- (tag.maximum.include
39
- ? ts.factory.createGreaterThanEquals
40
- : ts.factory.createGreaterThan)(
41
- ts.factory.createNumericLiteral(tag.maximum.value),
42
- length,
43
- ),
44
- );
45
- }
46
- }
1
+ import ts from "typescript";
2
+
3
+ import { IMetadataTag } from "../../metadata/IMetadataTag";
4
+
5
+ /**
6
+ * @internal
7
+ */
8
+ export function check_length(
9
+ conditions: ts.Expression[],
10
+ length: ts.Expression,
11
+ tag: Omit<IMetadataTag.ILength, "kind">,
12
+ ) {
13
+ if (
14
+ tag.minimum !== undefined &&
15
+ tag.maximum !== undefined &&
16
+ tag.minimum.value === tag.maximum.value &&
17
+ tag.minimum.include === true &&
18
+ tag.maximum.include === true
19
+ ) {
20
+ conditions.push(
21
+ ts.factory.createStrictEquality(
22
+ ts.factory.createNumericLiteral(tag.minimum.value),
23
+ length,
24
+ ),
25
+ );
26
+ } else {
27
+ if (tag.minimum !== undefined)
28
+ conditions.push(
29
+ (tag.minimum.include
30
+ ? ts.factory.createLessThanEquals
31
+ : ts.factory.createLessThan)(
32
+ ts.factory.createNumericLiteral(tag.minimum.value),
33
+ length,
34
+ ),
35
+ );
36
+ if (tag.maximum !== undefined)
37
+ conditions.push(
38
+ (tag.maximum.include
39
+ ? ts.factory.createGreaterThanEquals
40
+ : ts.factory.createGreaterThan)(
41
+ ts.factory.createNumericLiteral(tag.maximum.value),
42
+ length,
43
+ ),
44
+ );
45
+ }
46
+ }
@@ -1,9 +1,9 @@
1
- import ts from "typescript";
2
-
3
- import { ExpressionFactory } from "../../factories/ExpressionFactory";
4
-
5
- /**
6
- * @internal
7
- */
8
- export const check_native = (type: string) => (input: ts.Expression) =>
9
- ExpressionFactory.isInstanceOf(input, type);
1
+ import ts from "typescript";
2
+
3
+ import { ExpressionFactory } from "../../factories/ExpressionFactory";
4
+
5
+ /**
6
+ * @internal
7
+ */
8
+ export const check_native = (type: string) => (input: ts.Expression) =>
9
+ ExpressionFactory.isInstanceOf(input, type);
@@ -1,42 +1,43 @@
1
- import ts from "typescript";
2
-
3
- import { IExpressionEntry } from "../helpers/IExpressionEntry";
4
- import { check_dynamic_properties } from "./check_dynamic_properties";
5
- import { check_everything } from "./check_everything";
6
-
7
- /**
8
- * @internal
9
- */
10
- export const check_object =
11
- (props: check_object.IProps) => (entries: IExpressionEntry[]) => {
12
- // PREPARE ASSETS
13
- const regular = entries.filter((entry) => entry.key.isSoleLiteral());
14
- const dynamic = entries.filter((entry) => !entry.key.isSoleLiteral());
15
- const flags: ts.Expression[] = regular.map((entry) => entry.expression);
16
-
17
- // REGULAR WITHOUT DYNAMIC PROPERTIES
18
- if (props.equals === false && dynamic.length === 0)
19
- return regular.length === 0 ? props.positive : reduce(props)(flags);
20
-
21
- // CHECK DYNAMIC PROPERTIES
22
- flags.push(check_dynamic_properties(props)(regular, dynamic));
23
- return reduce(props)(flags);
24
- };
25
- export namespace check_object {
26
- export interface IProps {
27
- equals: boolean;
28
- assert: boolean;
29
- halt?: (exp: ts.Expression) => ts.Expression;
30
- reduce: (a: ts.Expression, b: ts.Expression) => ts.Expression;
31
- positive: ts.Expression;
32
- superfluous: (value: ts.Expression) => ts.Expression;
33
- entries?: ts.Identifier;
34
- }
35
- }
36
-
37
- const reduce = (props: check_object.IProps) => (expressions: ts.Expression[]) =>
38
- props.assert
39
- ? expressions.reduce(props.reduce)
40
- : check_everything(
41
- ts.factory.createArrayLiteralExpression(expressions),
42
- );
1
+ import ts from "typescript";
2
+
3
+ import { IExpressionEntry } from "../helpers/IExpressionEntry";
4
+ import { check_dynamic_properties } from "./check_dynamic_properties";
5
+ import { check_everything } from "./check_everything";
6
+
7
+ /**
8
+ * @internal
9
+ */
10
+ export const check_object =
11
+ (props: check_object.IProps) => (entries: IExpressionEntry[]) => {
12
+ // PREPARE ASSETS
13
+ const regular = entries.filter((entry) => entry.key.isSoleLiteral());
14
+ const dynamic = entries.filter((entry) => !entry.key.isSoleLiteral());
15
+ const flags: ts.Expression[] = regular.map((entry) => entry.expression);
16
+
17
+ // REGULAR WITHOUT DYNAMIC PROPERTIES
18
+ if (props.equals === false && dynamic.length === 0)
19
+ return regular.length === 0 ? props.positive : reduce(props)(flags);
20
+
21
+ // CHECK DYNAMIC PROPERTIES
22
+ flags.push(check_dynamic_properties(props)(regular, dynamic));
23
+ return reduce(props)(flags);
24
+ };
25
+ export namespace check_object {
26
+ export interface IProps {
27
+ equals: boolean;
28
+ assert: boolean;
29
+ undefined: boolean;
30
+ halt?: (exp: ts.Expression) => ts.Expression;
31
+ reduce: (a: ts.Expression, b: ts.Expression) => ts.Expression;
32
+ positive: ts.Expression;
33
+ superfluous: (value: ts.Expression) => ts.Expression;
34
+ entries?: ts.Identifier;
35
+ }
36
+ }
37
+
38
+ const reduce = (props: check_object.IProps) => (expressions: ts.Expression[]) =>
39
+ props.assert
40
+ ? expressions.reduce(props.reduce)
41
+ : check_everything(
42
+ ts.factory.createArrayLiteralExpression(expressions),
43
+ );