Skip to content

Commit

Permalink
Test #1429, but no problem
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Dec 13, 2024
1 parent 0e7b90a commit fb55b9d
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/generate/input/generate_issue_1429.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import typia from "typia";

type Person = {
name: string;
age: number;
};

export const validateParsePerson = typia.json.createValidateParse<Person>();
76 changes: 76 additions & 0 deletions test/generate/output/generate_issue_1429.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import typia from "typia";
import * as __typia_transform__validateReport from "typia/lib/internal/_validateReport.js";

type Person = {
name: string;
age: number;
};
export const validateParsePerson = (() => {
const _io0 = (input: any): boolean =>
"string" === typeof input.name &&
"number" === typeof input.age &&
Number.isFinite(input.age);
const _vo0 = (
input: any,
_path: string,
_exceptionable: boolean = true,
): boolean =>
[
"string" === typeof input.name ||
_report(_exceptionable, {
path: _path + ".name",
expected: "string",
value: input.name,
}),
("number" === typeof input.age && Number.isFinite(input.age)) ||
_report(_exceptionable, {
path: _path + ".age",
expected: "number",
value: input.age,
}),
].every((flag: boolean) => flag);
const __is = (input: any): input is Person =>
"object" === typeof input && null !== input && _io0(input);
let errors: any;
let _report: any;
const __validate = (input: any): import("typia").IValidation<Person> => {
if (false === __is(input)) {
errors = [];
_report = (__typia_transform__validateReport._validateReport as any)(
errors,
);
((input: any, _path: string, _exceptionable: boolean = true) =>
((("object" === typeof input && null !== input) ||
_report(true, {
path: _path + "",
expected: "Person",
value: input,
})) &&
_vo0(input, _path + "", true)) ||
_report(true, {
path: _path + "",
expected: "Person",
value: input,
}))(input, "$input", true);
const success = 0 === errors.length;
return success
? {
success,
data: input,
}
: ({
success,
errors,
data: input,
} as any);
}
return {
success: true,
data: input,
} as any;
};
return (
input: string,
): import("typia").IValidation<import("typia").Primitive<Person>> =>
__validate(JSON.parse(input)) as any;
})();

0 comments on commit fb55b9d

Please sign in to comment.