Skip to content

Commit

Permalink
Merge branch 'master' into features/encode
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Aug 14, 2023
2 parents 469a7a1 + ef88a0b commit 5f0a6d6
Show file tree
Hide file tree
Showing 160 changed files with 4,331 additions and 238 deletions.
2 changes: 1 addition & 1 deletion src/programmers/helpers/RandomRanger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export namespace RandomRanger {

props.minimum ??= defs.minimum;
props.maximum ??= defs.maximum;
if (props.maximum <= props.minimum)
if (props.maximum < props.minimum)
(props.maximum as number) += defs.gap;

return ts.factory.createCallExpression(
Expand Down
8 changes: 8 additions & 0 deletions src/programmers/json/JsonStringifyProgrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,12 @@ export namespace JsonStringifyProgrammer {
validate: (meta) => {
if (meta.atomics.find((str) => str === "bigint"))
throw new Error(NO_BIGINT);
else if (
meta.arrays.some(
(array) => array.value.isRequired() === false,
)
)
throw new Error(NO_UNDEFINED_IN_ARRAY);
},
})(collection)(type);
return [collection, meta];
Expand Down Expand Up @@ -977,3 +983,5 @@ interface IUnion {

const NO_BIGINT =
"Error on typia.json.stringify(): does not allow bigint type.";
const NO_UNDEFINED_IN_ARRAY =
"Error on typia.json.stringify(): does not allow undefined type in array.";
15 changes: 12 additions & 3 deletions src/transformers/features/json/JsonApplicationTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ export namespace JsonApplicationTransformer {
validate: (meta) => {
if (meta.atomics.find((str) => str === "bigint"))
throw new Error(NO_BIGIT);
else if (
meta.arrays.some(
(array) => array.value.isRequired() === false,
)
)
throw new Error(NO_UNDEFINED_IN_ARRAY);
},
})(collection)(type),
);
Expand Down Expand Up @@ -96,7 +102,10 @@ export namespace JsonApplicationTransformer {
}

const NO_GENERIC_ARGUMENT =
"Error on typia.application(): no generic argument.";
"Error on typia.json.application(): no generic argument.";
const GENERIC_ARGUMENT =
"Error on typia.application(): non-specified generic argument(s).";
const NO_BIGIT = "Error on typia.application(): does not allow bigint type.";
"Error on typia.json.application(): non-specified generic argument(s).";
const NO_BIGIT =
"Error on typia.json.application(): does not allow bigint type.";
const NO_UNDEFINED_IN_ARRAY =
"Error on typia.json.application(): does not allow undefined type in array.";
59 changes: 59 additions & 0 deletions test/generated/output/assert/test_assert_TagArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ export const test_assert_TagArray = _test_assert<TagArray>(TagArray)((input) =>
7 >= input.both.length &&
input.both.every(
(elem: any) => "string" === typeof elem && $is_uuid(elem),
) &&
Array.isArray(input.equal) &&
10 <= input.equal.length &&
10 >= input.equal.length &&
input.equal.every(
(elem: any) =>
"number" === typeof elem && 10 <= elem && 10 >= elem,
);
return "object" === typeof input && null !== input && $io0(input);
};
Expand Down Expand Up @@ -196,6 +203,58 @@ export const test_assert_TagArray = _test_assert<TagArray>(TagArray)((input) =>
path: _path + ".both",
expected: "Array<string>",
value: input.both,
})) &&
((((Array.isArray(input.equal) &&
(10 <= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array.length (@minItems 10)",
value: input.equal,
})) &&
(10 >= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array.length (@maxItems 10)",
value: input.equal,
}))) ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array<number>",
value: input.equal,
})) &&
input.equal.every(
(elem: any, _index5: number) =>
("number" === typeof elem &&
(10 <= elem ||
$guard(_exceptionable, {
path:
_path +
".equal[" +
_index5 +
"]",
expected: "number (@minimum 10)",
value: elem,
})) &&
(10 >= elem ||
$guard(_exceptionable, {
path:
_path +
".equal[" +
_index5 +
"]",
expected: "number (@maximum 10)",
value: elem,
}))) ||
$guard(_exceptionable, {
path: _path + ".equal[" + _index5 + "]",
expected: "number",
value: elem,
}),
)) ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array<number>",
value: input.equal,
}));
return (
((("object" === typeof input && null !== input) ||
Expand Down
23 changes: 22 additions & 1 deletion test/generated/output/assert/test_assert_TagLength.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export const test_assert_TagLength = _test_assert<TagLength>(TagLength)(
7 >= input.maximum.length &&
"string" === typeof input.minimum_and_maximum &&
3 <= input.minimum_and_maximum.length &&
7 >= input.minimum_and_maximum.length;
7 >= input.minimum_and_maximum.length &&
"string" === typeof input.equal &&
10 <= input.equal.length &&
19 >= input.equal.length;
return (
"object" === typeof input && null !== input && $io0(input)
);
Expand Down Expand Up @@ -133,6 +136,24 @@ export const test_assert_TagLength = _test_assert<TagLength>(TagLength)(
path: _path + ".minimum_and_maximum",
expected: "string",
value: input.minimum_and_maximum,
})) &&
(("string" === typeof input.equal &&
(10 <= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "string (@minLength 10)",
value: input.equal,
})) &&
(19 >= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "string (@maxLength 19)",
value: input.equal,
}))) ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "string",
value: input.equal,
}));
return (
((("object" === typeof input && null !== input) ||
Expand Down
23 changes: 22 additions & 1 deletion test/generated/output/assert/test_assert_TagRange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export const test_assert_TagRange = _test_assert<TagRange>(TagRange)((input) =>
7 >= input.greater_less_equal &&
"number" === typeof input.greater_equal_less_equal &&
3 <= input.greater_equal_less_equal &&
7 >= input.greater_equal_less_equal;
7 >= input.greater_equal_less_equal &&
"number" === typeof input.equal &&
10 <= input.equal &&
10 >= input.equal;
return "object" === typeof input && null !== input && $io0(input);
};
if (false === __is(input))
Expand Down Expand Up @@ -208,6 +211,24 @@ export const test_assert_TagRange = _test_assert<TagRange>(TagRange)((input) =>
path: _path + ".greater_equal_less_equal",
expected: "number",
value: input.greater_equal_less_equal,
})) &&
(("number" === typeof input.equal &&
(10 <= input.equal ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "number (@minimum 10)",
value: input.equal,
})) &&
(10 >= input.equal ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "number (@maximum 10)",
value: input.equal,
}))) ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "number",
value: input.equal,
}));
return (
((("object" === typeof input && null !== input) ||
Expand Down
67 changes: 63 additions & 4 deletions test/generated/output/assertEquals/test_assertEquals_TagArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,17 @@ export const test_assertEquals_TagArray = _test_assertEquals<TagArray>(
(elem: any, _index4: number) =>
"string" === typeof elem && $is_uuid(elem),
) &&
(3 === Object.keys(input).length ||
Array.isArray(input.equal) &&
10 <= input.equal.length &&
10 >= input.equal.length &&
input.equal.every(
(elem: any, _index5: number) =>
"number" === typeof elem && 10 <= elem && 10 >= elem,
) &&
(4 === Object.keys(input).length ||
Object.keys(input).every((key: any) => {
if (
["items", "minItems", "both"].some(
["items", "minItems", "both", "equal"].some(
(prop: any) => key === prop,
)
)
Expand Down Expand Up @@ -248,11 +255,63 @@ export const test_assertEquals_TagArray = _test_assertEquals<TagArray>(
expected: "Array<string>",
value: input.both,
})) &&
(3 === Object.keys(input).length ||
((((Array.isArray(input.equal) &&
(10 <= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array.length (@minItems 10)",
value: input.equal,
})) &&
(10 >= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array.length (@maxItems 10)",
value: input.equal,
}))) ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array<number>",
value: input.equal,
})) &&
input.equal.every(
(elem: any, _index5: number) =>
("number" === typeof elem &&
(10 <= elem ||
$guard(_exceptionable, {
path:
_path +
".equal[" +
_index5 +
"]",
expected: "number (@minimum 10)",
value: elem,
})) &&
(10 >= elem ||
$guard(_exceptionable, {
path:
_path +
".equal[" +
_index5 +
"]",
expected: "number (@maximum 10)",
value: elem,
}))) ||
$guard(_exceptionable, {
path: _path + ".equal[" + _index5 + "]",
expected: "number",
value: elem,
}),
)) ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "Array<number>",
value: input.equal,
})) &&
(4 === Object.keys(input).length ||
false === _exceptionable ||
Object.keys(input).every((key: any) => {
if (
["items", "minItems", "both"].some(
["items", "minItems", "both", "equal"].some(
(prop: any) => key === prop,
)
)
Expand Down
27 changes: 25 additions & 2 deletions test/generated/output/assertEquals/test_assertEquals_TagLength.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,18 @@ export const test_assertEquals_TagLength = _test_assertEquals<TagLength>(
"string" === typeof input.minimum_and_maximum &&
3 <= input.minimum_and_maximum.length &&
7 >= input.minimum_and_maximum.length &&
(4 === Object.keys(input).length ||
"string" === typeof input.equal &&
10 <= input.equal.length &&
19 >= input.equal.length &&
(5 === Object.keys(input).length ||
Object.keys(input).every((key: any) => {
if (
[
"fixed",
"minimum",
"maximum",
"minimum_and_maximum",
"equal",
].some((prop: any) => key === prop)
)
return true;
Expand Down Expand Up @@ -176,7 +180,25 @@ export const test_assertEquals_TagLength = _test_assertEquals<TagLength>(
expected: "string",
value: input.minimum_and_maximum,
})) &&
(4 === Object.keys(input).length ||
(("string" === typeof input.equal &&
(10 <= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "string (@minLength 10)",
value: input.equal,
})) &&
(19 >= input.equal.length ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "string (@maxLength 19)",
value: input.equal,
}))) ||
$guard(_exceptionable, {
path: _path + ".equal",
expected: "string",
value: input.equal,
})) &&
(5 === Object.keys(input).length ||
false === _exceptionable ||
Object.keys(input).every((key: any) => {
if (
Expand All @@ -185,6 +207,7 @@ export const test_assertEquals_TagLength = _test_assertEquals<TagLength>(
"minimum",
"maximum",
"minimum_and_maximum",
"equal",
].some((prop: any) => key === prop)
)
return true;
Expand Down
Loading

0 comments on commit 5f0a6d6

Please sign in to comment.