diff --git a/benchmark/package.json b/benchmark/package.json index 71f408a3a9..5cccb666c0 100644 --- a/benchmark/package.json +++ b/benchmark/package.json @@ -72,6 +72,6 @@ "suppress-warnings": "^1.0.2", "tstl": "^3.0.0", "uuid": "^9.0.1", - "typia": "../typia-7.0.0-dev.20241112.tgz" + "typia": "../typia-7.0.0-dev.20241114.tgz" } } \ No newline at end of file diff --git a/package.json b/package.json index 3ad722220d..d9160d37e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typia", - "version": "7.0.0-dev.20241112", + "version": "7.0.0-dev.20241114", "description": "Superfast runtime validators with only one line", "main": "lib/index.js", "typings": "lib/index.d.ts", diff --git a/packages/typescript-json/package.json b/packages/typescript-json/package.json index 62488afdfe..994d217d16 100644 --- a/packages/typescript-json/package.json +++ b/packages/typescript-json/package.json @@ -1,6 +1,6 @@ { "name": "typescript-json", - "version": "7.0.0-dev.20241112", + "version": "7.0.0-dev.20241114", "description": "Superfast runtime validators with only one line", "main": "lib/index.js", "typings": "lib/index.d.ts", @@ -64,7 +64,7 @@ }, "homepage": "https://typia.io", "dependencies": { - "typia": "7.0.0-dev.20241112" + "typia": "7.0.0-dev.20241114" }, "peerDependencies": { "typescript": ">=4.8.0 <5.7.0" diff --git a/packages/typescript-json/tsconfig.json b/packages/typescript-json/tsconfig.json index f3914ece9a..1d4b4395e1 100644 --- a/packages/typescript-json/tsconfig.json +++ b/packages/typescript-json/tsconfig.json @@ -11,7 +11,7 @@ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ /* Language and Environment */ - "target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + "target": "ES2015", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ "lib": [ "DOM", "ES2020" diff --git a/src/factories/ExpressionFactory.ts b/src/factories/ExpressionFactory.ts index b5fee9998e..c8a52c6f9d 100644 --- a/src/factories/ExpressionFactory.ts +++ b/src/factories/ExpressionFactory.ts @@ -1,5 +1,7 @@ import ts from "typescript"; +import { ImportProgrammer } from "../programmers/ImportProgrammer"; + import { _randomFormatUuid } from "../internal/_randomFormatUuid"; export namespace ExpressionFactory { @@ -129,13 +131,14 @@ export namespace ExpressionFactory { props.input.getSourceFile(), ); - export const transpile = ( - transformer: ts.TransformationContext, - script: string, - ) => { + export const transpile = (props: { + transformer?: ts.TransformationContext; + importer?: ImportProgrammer; + script: string; + }) => { const file: ts.SourceFile = ts.createSourceFile( `${_randomFormatUuid()}.ts`, - script, + props.script, ts.ScriptTarget.ESNext, true, ts.ScriptKind.TS, @@ -152,13 +155,64 @@ export namespace ExpressionFactory { return (input: ts.Expression): ts.Expression => { const visitor = (node: ts.Node): ts.Node => { if (ts.isIdentifier(node) && node.text === "$input") return input; + else if (props.importer !== undefined && ts.isCallExpression(node)) + if ( + node.expression.getText() === "$importInternal" && + node.arguments.length === 1 && + ts.isStringLiteralLike(node.arguments[0]!) + ) { + const name: string = node.arguments[0]!.text; + return props.importer.internal(name); + } else if ( + node.expression.getText() === "$importInstance" && + node.arguments.length === 2 && + ts.isStringLiteralLike(node.arguments[0]!) && + ts.isStringLiteralLike(node.arguments[1]!) + ) { + const name: string = node.arguments[0]!.text; + const file: string = node.arguments[1]!.text; + return props.importer.instance({ + file, + name, + alias: null, + type: false, + }); + } else if ( + node.expression.getText() === "$importNamespace" && + node.arguments.length === 2 && + ts.isStringLiteralLike(node.arguments[0]!) && + ts.isStringLiteralLike(node.arguments[1]!) + ) { + const name: string = node.arguments[0]!.text; + const file: string = node.arguments[1]!.text; + return props.importer.namespace({ + file, + name, + type: false, + }); + } else if ( + node.expression.getText() === "$importDefault" && + node.arguments.length === 3 && + ts.isStringLiteralLike(node.arguments[0]!) && + ts.isStringLiteralLike(node.arguments[1]!) + ) { + const name: string = node.arguments[0]!.text; + const file: string = node.arguments[1]!.text; + return props.importer.default({ + file, + name, + type: false, + }); + } return ts.visitEachChild( - (ts.factory as any).cloneNode(node), + ts.factory.cloneNode(node), visitor, - transformer, + props.transformer, ); }; - return visitor(statement.expression) as ts.Expression; + return visitor( + ts.factory.cloneNode(statement.expression), + ) as ts.Expression; }; }; } diff --git a/src/factories/MetadataFactory.ts b/src/factories/MetadataFactory.ts index eb266f9cde..229b95a45d 100644 --- a/src/factories/MetadataFactory.ts +++ b/src/factories/MetadataFactory.ts @@ -149,32 +149,29 @@ export namespace MetadataFactory { }; const validateMeta = (props: { - transformer?: ts.TransformationContext; options: IOptions; visitor: IValidationVisitor; metadata: Metadata; explore: IExplore; }) => { const result: string[] = []; - if (props.transformer !== undefined) - for (const atomic of props.metadata.atomics) - for (const row of atomic.tags) - for (const tag of row.filter( - (t) => t.validate !== undefined && t.predicate === undefined, - )) - try { - tag.predicate = ExpressionFactory.transpile( - props.transformer, - tag.validate!, - ); - } catch { - result.push( - `Unable to transpile type tag script: ${JSON.stringify( - tag.validate, - )}`, - ); - tag.predicate = () => ts.factory.createTrue(); - } + for (const atomic of props.metadata.atomics) + for (const row of atomic.tags) + for (const tag of row.filter( + (t) => t.validate !== undefined && t.predicate === undefined, + )) + try { + tag.predicate = ExpressionFactory.transpile({ + script: tag.validate!, + }); + } catch { + result.push( + `Unable to transpile type tag script: ${JSON.stringify( + tag.validate, + )}`, + ); + tag.predicate = () => ts.factory.createTrue(); + } result.push(...props.visitor.functor(props.metadata, props.explore)); if (result.length) props.visitor.errors.push({ diff --git a/src/internal/_isFormatByte.ts b/src/internal/_isFormatByte.ts new file mode 100644 index 0000000000..807f6b67eb --- /dev/null +++ b/src/internal/_isFormatByte.ts @@ -0,0 +1,7 @@ +export const _isFormatByte = (str: string): boolean => { + PATTERN.lastIndex = 0; + return PATTERN.test(str); +}; + +const PATTERN = + /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm; diff --git a/src/internal/_isFormatDate.ts b/src/internal/_isFormatDate.ts new file mode 100644 index 0000000000..abd17036e8 --- /dev/null +++ b/src/internal/_isFormatDate.ts @@ -0,0 +1,3 @@ +export const _isFormatDate = (str: string): boolean => FORMAT.test(str); + +const FORMAT = /^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/; diff --git a/src/internal/_isFormatDateTime.ts b/src/internal/_isFormatDateTime.ts new file mode 100644 index 0000000000..8836480bd5 --- /dev/null +++ b/src/internal/_isFormatDateTime.ts @@ -0,0 +1,4 @@ +export const _isFormatDateTime = (str: string): boolean => PATTERN.test(str); + +const PATTERN = + /^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(T|\s)([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i; diff --git a/src/internal/_isFormatDuration.ts b/src/internal/_isFormatDuration.ts new file mode 100644 index 0000000000..8d11b6849a --- /dev/null +++ b/src/internal/_isFormatDuration.ts @@ -0,0 +1,4 @@ +export const _isFormatDuration = (str: string): boolean => PATTERN.test(str); + +const PATTERN = + /^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/; diff --git a/src/internal/_isFormatEmail.ts b/src/internal/_isFormatEmail.ts new file mode 100644 index 0000000000..b0d8924afd --- /dev/null +++ b/src/internal/_isFormatEmail.ts @@ -0,0 +1,4 @@ +export const _isFormatEmail = (str: string): boolean => PATTERN.test(str); + +const PATTERN = + /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i; diff --git a/src/internal/_isFormatHostname.ts b/src/internal/_isFormatHostname.ts new file mode 100644 index 0000000000..4a723fc85d --- /dev/null +++ b/src/internal/_isFormatHostname.ts @@ -0,0 +1,4 @@ +export const _isFormatHostname = (str: string): boolean => PATTERN.test(str); + +const PATTERN = + /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i; diff --git a/src/internal/_isFormatIdnEmail.ts b/src/internal/_isFormatIdnEmail.ts new file mode 100644 index 0000000000..4b4f4a837e --- /dev/null +++ b/src/internal/_isFormatIdnEmail.ts @@ -0,0 +1,4 @@ +export const _isFormatIdnEmail = (str: string): boolean => PATTERN.test(str); + +const PATTERN = + /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i; diff --git a/src/internal/_isFormatIdnHostname.ts b/src/internal/_isFormatIdnHostname.ts new file mode 100644 index 0000000000..5f4ea6ac59 --- /dev/null +++ b/src/internal/_isFormatIdnHostname.ts @@ -0,0 +1,4 @@ +export const _isFormatIdnHostname = (str: string): boolean => PATTERN.test(str); + +const PATTERN = + /^([a-z0-9\u00a1-\uffff0-9]+(-[a-z0-9\u00a1-\uffff0-9]+)*\.)+[a-z\u00a1-\uffff]{2,}$/i; diff --git a/src/internal/_isFormatIpv4.ts b/src/internal/_isFormatIpv4.ts new file mode 100644 index 0000000000..c732d75f70 --- /dev/null +++ b/src/internal/_isFormatIpv4.ts @@ -0,0 +1,4 @@ +export const _isFormatIpv4 = (str: string): boolean => PATTERN.test(str); + +const PATTERN = + /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/; diff --git a/src/internal/_isFormatIpv6.ts b/src/internal/_isFormatIpv6.ts new file mode 100644 index 0000000000..a017d1dac1 --- /dev/null +++ b/src/internal/_isFormatIpv6.ts @@ -0,0 +1,4 @@ +export const _isFormatIpv6 = (str: string): boolean => PATTERN.test(str); + +const PATTERN = + /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i; diff --git a/src/internal/_isFormatIri.ts b/src/internal/_isFormatIri.ts new file mode 100644 index 0000000000..414b48e5a8 --- /dev/null +++ b/src/internal/_isFormatIri.ts @@ -0,0 +1,3 @@ +export const _isFormatIri = (str: string): boolean => PATTERN.test(str); + +const PATTERN = /^[A-Za-z][\d+-.A-Za-z]*:[^\u0000-\u0020"<>\\^`{|}]*$/u; diff --git a/src/internal/_isFormatIriReference.ts b/src/internal/_isFormatIriReference.ts new file mode 100644 index 0000000000..5a7dc7618b --- /dev/null +++ b/src/internal/_isFormatIriReference.ts @@ -0,0 +1,4 @@ +export const _isFormatIriReference = (str: string): boolean => + PATTERN.test(str); + +const PATTERN = /^[A-Za-z][\d+-.A-Za-z]*:[^\u0000-\u0020"<>\\^`{|}]*$/u; diff --git a/src/internal/_isFormatJsonPointer.ts b/src/internal/_isFormatJsonPointer.ts new file mode 100644 index 0000000000..2c24a3ab73 --- /dev/null +++ b/src/internal/_isFormatJsonPointer.ts @@ -0,0 +1,3 @@ +export const _isFormatJsonPointer = (str: string): boolean => PATTERN.test(str); + +const PATTERN = /^(?:\/(?:[^~/]|~0|~1)*)*$/; diff --git a/src/internal/_isFormatPassword.ts b/src/internal/_isFormatPassword.ts new file mode 100644 index 0000000000..787ce5ae34 --- /dev/null +++ b/src/internal/_isFormatPassword.ts @@ -0,0 +1 @@ +export const _isFormatPassword = (): boolean => true; diff --git a/src/internal/_isFormatRegex.ts b/src/internal/_isFormatRegex.ts new file mode 100644 index 0000000000..e92d04c322 --- /dev/null +++ b/src/internal/_isFormatRegex.ts @@ -0,0 +1,8 @@ +export const _isFormatRegex = (str: string): boolean => { + try { + new RegExp(str); + return true; + } catch { + return false; + } +}; diff --git a/src/internal/_isFormatRelativeJsonPointer.ts b/src/internal/_isFormatRelativeJsonPointer.ts new file mode 100644 index 0000000000..d0faf5f834 --- /dev/null +++ b/src/internal/_isFormatRelativeJsonPointer.ts @@ -0,0 +1,4 @@ +export const _isFormatRelativeJsonPointer = (str: string): boolean => + PATTERN.test(str); + +const PATTERN = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/; diff --git a/src/internal/_isFormatTime.ts b/src/internal/_isFormatTime.ts new file mode 100644 index 0000000000..8dbc566742 --- /dev/null +++ b/src/internal/_isFormatTime.ts @@ -0,0 +1,4 @@ +export const _isFormatTime = (str: string): boolean => PATTERN.test(str); + +const PATTERN = + /^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i; diff --git a/src/internal/_isFormatUri.ts b/src/internal/_isFormatUri.ts new file mode 100644 index 0000000000..d28fbc2355 --- /dev/null +++ b/src/internal/_isFormatUri.ts @@ -0,0 +1,6 @@ +export const _isFormatUri = (str: string): boolean => + NOT_URI_FRAGMENT.test(str) && URI.test(str); + +const NOT_URI_FRAGMENT = /\/|:/; +const URI = + /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i; diff --git a/src/internal/_isFormatUriReference.ts b/src/internal/_isFormatUriReference.ts new file mode 100644 index 0000000000..c39296646d --- /dev/null +++ b/src/internal/_isFormatUriReference.ts @@ -0,0 +1,5 @@ +export const _isFormatUriReference = (str: string): boolean => + PATTERN.test(str); + +const PATTERN = + /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i; diff --git a/src/internal/_isFormatUriTemplate.ts b/src/internal/_isFormatUriTemplate.ts new file mode 100644 index 0000000000..254dc35c37 --- /dev/null +++ b/src/internal/_isFormatUriTemplate.ts @@ -0,0 +1,4 @@ +export const _isFormatUriTemplate = (str: string): boolean => PATTERN.test(str); + +const PATTERN = + /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i; diff --git a/src/internal/_isFormatUrl.ts b/src/internal/_isFormatUrl.ts new file mode 100644 index 0000000000..39eb65faa9 --- /dev/null +++ b/src/internal/_isFormatUrl.ts @@ -0,0 +1,4 @@ +export const _isFormatUrl = (str: string): boolean => PATTERN.test(str); + +const PATTERN = + /^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu; diff --git a/src/internal/_isFormatUuid.ts b/src/internal/_isFormatUuid.ts new file mode 100644 index 0000000000..faa18eaed1 --- /dev/null +++ b/src/internal/_isFormatUuid.ts @@ -0,0 +1,3 @@ +export const _isFormatUuid = (str: string): boolean => PATTERN.test(str); + +const PATTERN = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i; diff --git a/src/internal/_isTypeFloat.ts b/src/internal/_isTypeFloat.ts new file mode 100644 index 0000000000..6a0f0392e9 --- /dev/null +++ b/src/internal/_isTypeFloat.ts @@ -0,0 +1,5 @@ +export const _isTypeFloat = (value: number): boolean => + MINIMUM <= value && value <= MAXIMUM; + +const MINIMUM = -1.175494351e38; +const MAXIMUM = 3.4028235e38; diff --git a/src/internal/_isTypeInt32.ts b/src/internal/_isTypeInt32.ts new file mode 100644 index 0000000000..0454b080fb --- /dev/null +++ b/src/internal/_isTypeInt32.ts @@ -0,0 +1,5 @@ +export const _isTypeInt32 = (value: number): boolean => + Math.floor(value) === value && MINIMUM <= value && value <= MAXIMUM; + +const MINIMUM = -(2 ** 31); +const MAXIMUM = 2 ** 31 - 1; diff --git a/src/internal/_isTypeInt64.ts b/src/internal/_isTypeInt64.ts new file mode 100644 index 0000000000..baa473e04b --- /dev/null +++ b/src/internal/_isTypeInt64.ts @@ -0,0 +1,5 @@ +export const _isTypeInt64 = (value: number): boolean => + Math.floor(value) === value && MINIMUM <= value && value <= MAXIMUM; + +const MINIMUM = -(2 ** 63); +const MAXIMUM = 2 ** 63 - 1; diff --git a/src/internal/_isTypeUint32.ts b/src/internal/_isTypeUint32.ts new file mode 100644 index 0000000000..dafa9ddf4a --- /dev/null +++ b/src/internal/_isTypeUint32.ts @@ -0,0 +1,5 @@ +export const _isTypeUint32 = (value: number): boolean => + Math.floor(value) === value && MINIMUM <= value && value <= MAXIMUM; + +const MINIMUM = 0; +const MAXIMUM = 2 ** 32 - 1; diff --git a/src/internal/_isTypeUint64.ts b/src/internal/_isTypeUint64.ts new file mode 100644 index 0000000000..d21024091f --- /dev/null +++ b/src/internal/_isTypeUint64.ts @@ -0,0 +1,5 @@ +export const _isTypeUint64 = (value: number): boolean => + Math.floor(value) === value && MINIMUM <= value && value <= MAXIMUM; + +const MINIMUM = 0; +const MAXIMUM = 2 ** 64 - 1; diff --git a/src/programmers/internal/check_array_length.ts b/src/programmers/internal/check_array_length.ts index cc3b40eedb..54b0996b0a 100644 --- a/src/programmers/internal/check_array_length.ts +++ b/src/programmers/internal/check_array_length.ts @@ -38,9 +38,10 @@ const check_array_type_tags = (props: { .map((row) => row.map((tag) => ({ expected: `Array<> & ${tag.name}`, - expression: ( - tag.predicate ?? - ExpressionFactory.transpile(props.context.transformer, tag.validate!) - )(props.input), + expression: ExpressionFactory.transpile({ + transformer: props.context.transformer, + importer: props.context.importer, + script: tag.validate!, + })(props.input), })), ); diff --git a/src/programmers/internal/check_bigint.ts b/src/programmers/internal/check_bigint.ts index c3e623ca83..05c94fd602 100644 --- a/src/programmers/internal/check_bigint.ts +++ b/src/programmers/internal/check_bigint.ts @@ -41,9 +41,10 @@ const check_bigint_type_tags = (props: { .map((row) => row.map((tag) => ({ expected: `bigint & ${tag.name}`, - expression: ( - tag.predicate ?? - ExpressionFactory.transpile(props.context.transformer, tag.validate!) - )(props.input), + expression: ExpressionFactory.transpile({ + transformer: props.context.transformer, + importer: props.context.importer, + script: tag.validate!, + })(props.input), })), ); diff --git a/src/programmers/internal/check_number.ts b/src/programmers/internal/check_number.ts index 70705d503a..66c574f8d3 100644 --- a/src/programmers/internal/check_number.ts +++ b/src/programmers/internal/check_number.ts @@ -103,9 +103,10 @@ const check_numeric_type_tags = (props: { ]), ...row.map((tag) => ({ expected: `number & ${tag.name}`, - expression: ( - tag.predicate ?? - ExpressionFactory.transpile(props.context.transformer, tag.validate!) - )(props.input), + expression: ExpressionFactory.transpile({ + transformer: props.context.transformer, + importer: props.context.importer, + script: tag.validate!, + })(props.input), })), ]); diff --git a/src/programmers/internal/check_string.ts b/src/programmers/internal/check_string.ts index b035841764..427302471a 100644 --- a/src/programmers/internal/check_string.ts +++ b/src/programmers/internal/check_string.ts @@ -41,9 +41,10 @@ const check_string_type_tags = (props: { .map((row) => row.map((tag) => ({ expected: `string & ${tag.name}`, - expression: ( - tag.predicate ?? - ExpressionFactory.transpile(props.context.transformer, tag.validate!) - )(props.input), + expression: ExpressionFactory.transpile({ + transformer: props.context.transformer, + importer: props.context.importer, + script: tag.validate!, + })(props.input), })), ); diff --git a/src/tags/Format.ts b/src/tags/Format.ts index 646024fb68..e6375ae7a1 100644 --- a/src/tags/Format.ts +++ b/src/tags/Format.ts @@ -1,16 +1,50 @@ import type { TagBase } from "./TagBase"; -import type { FormatCheatSheet } from "./internal/FormatCheatSheet"; -export type Format = TagBase<{ +export type Format = TagBase<{ target: "string"; kind: "format"; value: Value; - validate: Format.Validator[Value]; + validate: `$importInternal("isFormat${PascalizeString}")($input)`; exclusive: ["format", "pattern"]; schema: { format: Value; }; }>; export namespace Format { - export type Validator = typeof FormatCheatSheet; + export type Value = + | "byte" + | "password" + | "regex" + | "uuid" + | "email" + | "hostname" + | "idn-email" + | "idn-hostname" + | "iri" + | "iri-reference" + | "ipv4" + | "ipv6" + | "uri" + | "uri-reference" + | "uri-template" + | "url" + | "date-time" + | "date" + | "time" + | "duration" + | "json-pointer" + | "relative-json-pointer"; } + +type PascalizeString = Key extends `-${infer R}` + ? `${PascalizeString}` + : Key extends `${infer _F}-${infer _R}` + ? PascalizeSnakeString + : Capitalize; +type PascalizeSnakeString = Key extends `-${infer R}` + ? PascalizeSnakeString + : Key extends `${infer F}${infer M}-${infer R}` + ? `${Uppercase}${Lowercase}${PascalizeSnakeString}` + : Key extends `${infer F}${infer R}` + ? `${Uppercase}${Lowercase}` + : Key; diff --git a/src/tags/Type.ts b/src/tags/Type.ts index c473ef96e6..8f4ef63f4f 100644 --- a/src/tags/Type.ts +++ b/src/tags/Type.ts @@ -7,21 +7,21 @@ export type Type< kind: "type"; value: Value; validate: Value extends "int32" - ? `Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647` + ? `$importInternal("isTypeInt32")($input)` : Value extends "uint32" - ? `Math.floor($input) === $input && 0 <= $input && $input <= 4294967295` + ? `$importInternal("isTypeUint32")($input)` : Value extends "int64" ? { - number: `Math.floor($input) === $input && -9223372036854775808 <= $input && $input <= 9223372036854775807`; + number: `$importInternal("isTypeInt64")($input)`; bigint: `true`; } : Value extends "uint64" ? { - number: `Math.floor($input) === $input && 0 <= $input && $input <= 18446744073709551615`; + number: `$importInternal("isTypeUint64")($input)`; bigint: `BigInt(0) <= $input`; } : Value extends "float" - ? `-1.175494351e38 <= $input && $input <= 3.4028235e38` + ? `$importInternal("isTypeFloat")($input)` : `true`; exclusive: true; schema: { diff --git a/test-error/package.json b/test-error/package.json index 0233e0996d..300b29f58e 100644 --- a/test-error/package.json +++ b/test-error/package.json @@ -32,6 +32,6 @@ "typescript": "^5.3.2" }, "dependencies": { - "typia": "../typia-7.0.0-dev.20241112.tgz" + "typia": "../typia-7.0.0-dev.20241114.tgz" } } \ No newline at end of file diff --git a/test-esm/package.json b/test-esm/package.json index dcb221aa82..445f064a6f 100644 --- a/test-esm/package.json +++ b/test-esm/package.json @@ -36,6 +36,6 @@ "typescript": "^5.4.5" }, "dependencies": { - "typia": "../typia-7.0.0-dev.20241112.tgz" + "typia": "../typia-7.0.0-dev.20241114.tgz" } } \ No newline at end of file diff --git a/test/generate/input/generate_json.ts b/test/generate/input/generate_json.ts index e4c107bfea..144762fd4b 100644 --- a/test/generate/input/generate_json.ts +++ b/test/generate/input/generate_json.ts @@ -13,12 +13,12 @@ interface ICitizen { } export const createStringify = typia.json.createStringify(); -export const createIsStringify = typia.json.createIsStringify(); -export const createAssertStringify = - typia.json.createAssertStringify(); -export const createValidateStringify = - typia.json.createValidateStringify(); +// export const createIsStringify = typia.json.createIsStringify(); +// export const createAssertStringify = +// typia.json.createAssertStringify(); +// export const createValidateStringify = +// typia.json.createValidateStringify(); -export const createIsParse = typia.json.createIsParse(); -export const createAssertParse = typia.json.createAssertParse(); -export const createValidateParse = typia.json.createValidateParse(); +// export const createIsParse = typia.json.createIsParse(); +// export const createAssertParse = typia.json.createAssertParse(); +// export const createValidateParse = typia.json.createValidateParse(); diff --git a/test/generate/input/generate_misc.ts b/test/generate/input/generate_misc.ts index cbe5b590d2..b1607066e2 100644 --- a/test/generate/input/generate_misc.ts +++ b/test/generate/input/generate_misc.ts @@ -1,25 +1,25 @@ -import typia, { tags } from "typia"; +// import typia, { tags } from "typia"; -interface ICitizen { - id: string & tags.Format<"uuid">; - name: string & tags.Pattern<"^[A-Z][a-z]+$">; - email: string & tags.Format<"email">; - age: number & tags.Type<"uint32"> & tags.ExclusiveMaximum<100>; - motto: string; - birthdate: Date; - died_at: null | Date; - parent: ICitizen | null; - children: ICitizen[]; -} +// interface ICitizen { +// id: string & tags.Format<"uuid">; +// name: string & tags.Pattern<"^[A-Z][a-z]+$">; +// email: string & tags.Format<"email">; +// age: number & tags.Type<"uint32"> & tags.ExclusiveMaximum<100>; +// motto: string; +// birthdate: Date; +// died_at: null | Date; +// parent: ICitizen | null; +// children: ICitizen[]; +// } -export const createClone = typia.misc.createClone(); -export const createAssertClone = typia.misc.createAssertClone(); -export const createIsClone = typia.misc.createIsClone(); -export const createValidateClone = typia.misc.createValidateClone(); +// export const createClone = typia.misc.createClone(); +// export const createAssertClone = typia.misc.createAssertClone(); +// export const createIsClone = typia.misc.createIsClone(); +// export const createValidateClone = typia.misc.createValidateClone(); -export const createPrune = typia.misc.createPrune(); -export const createAssertPrune = typia.misc.createAssertPrune(); -export const createIsPrune = typia.misc.createIsPrune(); -export const createValidatePrune = typia.misc.createValidatePrune(); +// export const createPrune = typia.misc.createPrune(); +// export const createAssertPrune = typia.misc.createAssertPrune(); +// export const createIsPrune = typia.misc.createIsPrune(); +// export const createValidatePrune = typia.misc.createValidatePrune(); -export const literals = typia.misc.literals(); +// export const literals = typia.misc.literals(); diff --git a/test/generate/input/generate_notations.ts b/test/generate/input/generate_notations.ts index d59a39eaf0..c72c994595 100644 --- a/test/generate/input/generate_notations.ts +++ b/test/generate/input/generate_notations.ts @@ -1,32 +1,32 @@ -import typia, { tags } from "typia"; +// import typia, { tags } from "typia"; -interface ICitizen { - id: string & tags.Format<"uuid">; - name: string & tags.Pattern<"^[A-Z][a-z]+$">; - email: string & tags.Format<"email">; - age: number & tags.Type<"uint32"> & tags.ExclusiveMaximum<100>; - motto: string; - birthdate: Date; - died_at: null | Date; - parent: ICitizen | null; - children: ICitizen[]; -} +// interface ICitizen { +// id: string & tags.Format<"uuid">; +// name: string & tags.Pattern<"^[A-Z][a-z]+$">; +// email: string & tags.Format<"email">; +// age: number & tags.Type<"uint32"> & tags.ExclusiveMaximum<100>; +// motto: string; +// birthdate: Date; +// died_at: null | Date; +// parent: ICitizen | null; +// children: ICitizen[]; +// } -export const createCamel = typia.notations.createCamel(); -export const createAssertCamel = typia.notations.createAssertCamel(); -export const createIsCamel = typia.notations.createIsCamel(); -export const createValidateCamel = - typia.notations.createValidateCamel(); +// export const createCamel = typia.notations.createCamel(); +// export const createAssertCamel = typia.notations.createAssertCamel(); +// export const createIsCamel = typia.notations.createIsCamel(); +// export const createValidateCamel = +// typia.notations.createValidateCamel(); -export const createPascal = typia.notations.createPascal(); -export const createAssertPascal = - typia.notations.createAssertPascal(); -export const createIsPascal = typia.notations.createIsPascal(); -export const createValidatePascal = - typia.notations.createValidatePascal(); +// export const createPascal = typia.notations.createPascal(); +// export const createAssertPascal = +// typia.notations.createAssertPascal(); +// export const createIsPascal = typia.notations.createIsPascal(); +// export const createValidatePascal = +// typia.notations.createValidatePascal(); -export const createSnake = typia.notations.createSnake(); -export const createAssertSnake = typia.notations.createAssertSnake(); -export const createIsSnake = typia.notations.createIsSnake(); -export const createValidateSnake = - typia.notations.createValidateSnake(); +// export const createSnake = typia.notations.createSnake(); +// export const createAssertSnake = typia.notations.createAssertSnake(); +// export const createIsSnake = typia.notations.createIsSnake(); +// export const createValidateSnake = +// typia.notations.createValidateSnake(); diff --git a/test/generate/input/generate_plain.ts b/test/generate/input/generate_plain.ts index 2abd30c8b9..c35179c20e 100644 --- a/test/generate/input/generate_plain.ts +++ b/test/generate/input/generate_plain.ts @@ -1,27 +1,27 @@ -import typia, { tags } from "typia"; +// import typia, { tags } from "typia"; -interface ICitizen { - id: string & tags.Format<"uuid">; - name: string & tags.Pattern<"^[A-Z][a-z]+$">; - email: string & tags.Format<"email">; - age: number & tags.Type<"uint32"> & tags.ExclusiveMaximum<100>; - motto: string; - birthdate: Date; - died_at: null | Date; - parent: ICitizen | null; - children: ICitizen[]; -} +// interface ICitizen { +// id: string & tags.Format<"uuid">; +// name: string & tags.Pattern<"^[A-Z][a-z]+$">; +// email: string & tags.Format<"email">; +// age: number & tags.Type<"uint32"> & tags.ExclusiveMaximum<100>; +// motto: string; +// birthdate: Date; +// died_at: null | Date; +// parent: ICitizen | null; +// children: ICitizen[]; +// } -export const createIs = typia.createIs(); -export const createEquals = typia.createEquals(); +// export const createIs = typia.createIs(); +// export const createEquals = typia.createEquals(); -export const createAssert = typia.createAssert(); -export const createAssertEquals = typia.createAssertEquals(); -export const createAssertGuard = typia.createAssertGuard(); -export const createAssertGuardEquals = - typia.createAssertGuardEquals(); +// export const createAssert = typia.createAssert(); +// export const createAssertEquals = typia.createAssertEquals(); +// export const createAssertGuard = typia.createAssertGuard(); +// export const createAssertGuardEquals = +// typia.createAssertGuardEquals(); -export const createValidate = typia.createValidate(); -export const createValidateEquals = typia.createValidateEquals(); +// export const createValidate = typia.createValidate(); +// export const createValidateEquals = typia.createValidateEquals(); -export const createRandom = typia.createRandom(); +// export const createRandom = typia.createRandom(); diff --git a/test/generate/input/generate_protobuf.ts b/test/generate/input/generate_protobuf.ts index b34281abb5..c85735b322 100644 --- a/test/generate/input/generate_protobuf.ts +++ b/test/generate/input/generate_protobuf.ts @@ -1,20 +1,20 @@ -import typia, { tags } from "typia"; +// import typia, { tags } from "typia"; -interface IFile { - name: string & tags.MaxLength<8>; - extension: null | (string & tags.MinLength<1> & tags.MaxLength<3>); - size: number & tags.Type<"uint32">; - data: Uint8Array; -} +// interface IFile { +// name: string & tags.MaxLength<8>; +// extension: null | (string & tags.MinLength<1> & tags.MaxLength<3>); +// size: number & tags.Type<"uint32">; +// data: Uint8Array; +// } -export const createEncode = typia.protobuf.createEncode(); -export const createAssertEncode = typia.protobuf.createAssertEncode(); -export const createIsEncode = typia.protobuf.createIsEncode(); -export const createValidateEncode = - typia.protobuf.createValidateEncode(); +// export const createEncode = typia.protobuf.createEncode(); +// export const createAssertEncode = typia.protobuf.createAssertEncode(); +// export const createIsEncode = typia.protobuf.createIsEncode(); +// export const createValidateEncode = +// typia.protobuf.createValidateEncode(); -export const createDecode = typia.protobuf.createDecode(); -export const createAssertDecode = typia.protobuf.createAssertDecode(); -export const createIsDecode = typia.protobuf.createIsDecode(); -export const createValidateDecode = - typia.protobuf.createValidateDecode(); +// export const createDecode = typia.protobuf.createDecode(); +// export const createAssertDecode = typia.protobuf.createAssertDecode(); +// export const createIsDecode = typia.protobuf.createIsDecode(); +// export const createValidateDecode = +// typia.protobuf.createValidateDecode(); diff --git a/test/generate/output/generate_json.ts b/test/generate/output/generate_json.ts index 32a96990f5..72a986a276 100644 --- a/test/generate/output/generate_json.ts +++ b/test/generate/output/generate_json.ts @@ -1,8 +1,9 @@ import typia, { tags } from "typia"; -import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard.js"; +import * as __typia_transform__isFormatEmail from "typia/lib/internal/_isFormatEmail.js"; +import * as __typia_transform__isFormatUuid from "typia/lib/internal/_isFormatUuid.js"; +import * as __typia_transform__isTypeUint32 from "typia/lib/internal/_isTypeUint32.js"; import * as __typia_transform__jsonStringifyNumber from "typia/lib/internal/_jsonStringifyNumber.js"; import * as __typia_transform__jsonStringifyString from "typia/lib/internal/_jsonStringifyString.js"; -import * as __typia_transform__validateReport from "typia/lib/internal/_validateReport.js"; interface ICitizen { id: string & tags.Format<"uuid">; @@ -20,19 +21,13 @@ export const createStringify = (() => { `{"id":${__typia_transform__jsonStringifyString._jsonStringifyString(input.id)},"name":${__typia_transform__jsonStringifyString._jsonStringifyString(input.name)},"email":${__typia_transform__jsonStringifyString._jsonStringifyString(input.email)},"age":${__typia_transform__jsonStringifyNumber._jsonStringifyNumber(input.age)},"motto":${__typia_transform__jsonStringifyString._jsonStringifyString(input.motto)},"birthdate":${__typia_transform__jsonStringifyString._jsonStringifyString(input.birthdate.toJSON())},"died_at":${null !== input.died_at ? __typia_transform__jsonStringifyString._jsonStringifyString(input.died_at.toJSON()) : "null"},"parent":${null !== input.parent ? _so0(input.parent) : "null"},"children":${`[${input.children.map((elem: any) => _so0(elem)).join(",")}]`}}`; const _io0 = (input: any): boolean => "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && + __typia_transform__isFormatUuid._isFormatUuid(input.id) && "string" === typeof input.name && RegExp("^[A-Z][a-z]+$").test(input.name) && "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && + __typia_transform__isFormatEmail._isFormatEmail(input.email) && "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && + __typia_transform__isTypeUint32._isTypeUint32(input.age) && input.age < 100 && "string" === typeof input.motto && input.birthdate instanceof Date && @@ -47,1055 +42,3 @@ export const createStringify = (() => { ); return (input: ICitizen): string => _so0(input); })(); -export const createIsStringify = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _so0 = (input: any): any => - `{"id":${__typia_transform__jsonStringifyString._jsonStringifyString(input.id)},"name":${__typia_transform__jsonStringifyString._jsonStringifyString(input.name)},"email":${__typia_transform__jsonStringifyString._jsonStringifyString(input.email)},"age":${__typia_transform__jsonStringifyNumber._jsonStringifyNumber(input.age)},"motto":${__typia_transform__jsonStringifyString._jsonStringifyString(input.motto)},"birthdate":${__typia_transform__jsonStringifyString._jsonStringifyString(input.birthdate.toJSON())},"died_at":${null !== input.died_at ? __typia_transform__jsonStringifyString._jsonStringifyString(input.died_at.toJSON()) : "null"},"parent":${null !== input.parent ? _so0(input.parent) : "null"},"children":${`[${input.children.map((elem: any) => _so0(elem)).join(",")}]`}}`; - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - const __stringify = (input: ICitizen): string => _so0(input); - return (input: any): string | null => - __is(input) ? __stringify(input) : null; -})(); -export const createAssertStringify = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _ao0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - (("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }, - _errorFactory, - )) && - (("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }, - _errorFactory, - )) && - (("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }, - _errorFactory, - )) && - (("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - }, - _errorFactory, - )) && - (input.age < 100 || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }, - _errorFactory, - )) && - ("string" === typeof input.motto || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".motto", - expected: "string", - value: input.motto, - }, - _errorFactory, - )) && - (input.birthdate instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }, - _errorFactory, - )) && - (null === input.died_at || - input.died_at instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }, - _errorFactory, - )) && - (null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - _ao0(input.parent, _path + ".parent", true && _exceptionable)) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - (((Array.isArray(input.children) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )) && - input.children.every( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - )) && - _ao0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - ), - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertStringify", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )); - const _so0 = (input: any): any => - `{"id":${__typia_transform__jsonStringifyString._jsonStringifyString(input.id)},"name":${__typia_transform__jsonStringifyString._jsonStringifyString(input.name)},"email":${__typia_transform__jsonStringifyString._jsonStringifyString(input.email)},"age":${__typia_transform__jsonStringifyNumber._jsonStringifyNumber(input.age)},"motto":${__typia_transform__jsonStringifyString._jsonStringifyString(input.motto)},"birthdate":${__typia_transform__jsonStringifyString._jsonStringifyString(input.birthdate.toJSON())},"died_at":${null !== input.died_at ? __typia_transform__jsonStringifyString._jsonStringifyString(input.died_at.toJSON()) : "null"},"parent":${null !== input.parent ? _so0(input.parent) : "null"},"children":${`[${input.children.map((elem: any) => _so0(elem)).join(",")}]`}}`; - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let _errorFactory: any; - const __assert = ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): ICitizen => { - if (false === __is(input)) { - _errorFactory = errorFactory; - ((input: any, _path: string, _exceptionable: boolean = true) => - ((("object" === typeof input && null !== input) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.json.createAssertStringify", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - )) && - _ao0(input, _path + "", true)) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.json.createAssertStringify", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - ))(input, "$input", true); - } - return input; - }; - const __stringify = (input: ICitizen): string => _so0(input); - return ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): string => { - __assert(input, errorFactory); - return __stringify(input); - }; -})(); -export const createValidateStringify = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _vo0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - [ - ("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - $report(_exceptionable, { - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }))) || - $report(_exceptionable, { - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }), - ("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - $report(_exceptionable, { - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }))) || - $report(_exceptionable, { - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }), - ("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - $report(_exceptionable, { - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }))) || - $report(_exceptionable, { - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }), - ("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - $report(_exceptionable, { - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - })) && - (input.age < 100 || - $report(_exceptionable, { - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }))) || - $report(_exceptionable, { - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }), - "string" === typeof input.motto || - $report(_exceptionable, { - path: _path + ".motto", - expected: "string", - value: input.motto, - }), - input.birthdate instanceof Date || - $report(_exceptionable, { - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }), - null === input.died_at || - input.died_at instanceof Date || - $report(_exceptionable, { - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }), - null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - })) && - _vo0(input.parent, _path + ".parent", true && _exceptionable)) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }), - ((Array.isArray(input.children) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - })) && - input.children - .map( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - })) && - _vo0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }), - ) - .every((flag: boolean) => flag)) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - }), - ].every((flag: boolean) => flag); - const _so0 = (input: any): any => - `{"id":${__typia_transform__jsonStringifyString._jsonStringifyString(input.id)},"name":${__typia_transform__jsonStringifyString._jsonStringifyString(input.name)},"email":${__typia_transform__jsonStringifyString._jsonStringifyString(input.email)},"age":${__typia_transform__jsonStringifyNumber._jsonStringifyNumber(input.age)},"motto":${__typia_transform__jsonStringifyString._jsonStringifyString(input.motto)},"birthdate":${__typia_transform__jsonStringifyString._jsonStringifyString(input.birthdate.toJSON())},"died_at":${null !== input.died_at ? __typia_transform__jsonStringifyString._jsonStringifyString(input.died_at.toJSON()) : "null"},"parent":${null !== input.parent ? _so0(input.parent) : "null"},"children":${`[${input.children.map((elem: any) => _so0(elem)).join(",")}]`}}`; - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let errors: any; - let $report: any; - const __validate = (input: any): import("typia").IValidation => { - 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: "ICitizen", - value: input, - })) && - _vo0(input, _path + "", true)) || - $report(true, { - path: _path + "", - expected: "ICitizen", - value: input, - }))(input, "$input", true); - const success = 0 === errors.length; - return { - success, - errors, - data: success ? input : undefined, - } as any; - } - return { - success: true, - errors: [], - data: input, - } as any; - }; - const __stringify = (input: ICitizen): string => _so0(input); - return (input: any): import("typia").IValidation => { - const result = __validate(input) as any; - if (result.success) result.data = __stringify(input); - return result; - }; -})(); -export const createIsParse = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - return (input: string): import("typia").Primitive | null => { - input = JSON.parse(input); - return __is(input) ? (input as any) : null; - }; -})(); -export const createAssertParse = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _ao0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - (("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }, - _errorFactory, - )) && - (("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }, - _errorFactory, - )) && - (("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }, - _errorFactory, - )) && - (("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - }, - _errorFactory, - )) && - (input.age < 100 || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }, - _errorFactory, - )) && - ("string" === typeof input.motto || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".motto", - expected: "string", - value: input.motto, - }, - _errorFactory, - )) && - (input.birthdate instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }, - _errorFactory, - )) && - (null === input.died_at || - input.died_at instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }, - _errorFactory, - )) && - (null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - _ao0(input.parent, _path + ".parent", true && _exceptionable)) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - (((Array.isArray(input.children) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )) && - input.children.every( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - )) && - _ao0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - ), - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.json.createAssertParse", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let _errorFactory: any; - const __assert = ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): ICitizen => { - if (false === __is(input)) { - _errorFactory = errorFactory; - ((input: any, _path: string, _exceptionable: boolean = true) => - ((("object" === typeof input && null !== input) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.json.createAssertParse", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - )) && - _ao0(input, _path + "", true)) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.json.createAssertParse", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - ))(input, "$input", true); - } - return input; - }; - return ( - input: string, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): import("typia").Primitive => - __assert(JSON.parse(input), errorFactory) as any; -})(); -export const createValidateParse = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _vo0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - [ - ("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - $report(_exceptionable, { - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }))) || - $report(_exceptionable, { - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }), - ("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - $report(_exceptionable, { - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }))) || - $report(_exceptionable, { - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }), - ("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - $report(_exceptionable, { - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }))) || - $report(_exceptionable, { - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }), - ("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - $report(_exceptionable, { - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - })) && - (input.age < 100 || - $report(_exceptionable, { - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }))) || - $report(_exceptionable, { - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }), - "string" === typeof input.motto || - $report(_exceptionable, { - path: _path + ".motto", - expected: "string", - value: input.motto, - }), - input.birthdate instanceof Date || - $report(_exceptionable, { - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }), - null === input.died_at || - input.died_at instanceof Date || - $report(_exceptionable, { - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }), - null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - })) && - _vo0(input.parent, _path + ".parent", true && _exceptionable)) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }), - ((Array.isArray(input.children) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - })) && - input.children - .map( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - })) && - _vo0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }), - ) - .every((flag: boolean) => flag)) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - }), - ].every((flag: boolean) => flag); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let errors: any; - let $report: any; - const __validate = (input: any): import("typia").IValidation => { - 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: "ICitizen", - value: input, - })) && - _vo0(input, _path + "", true)) || - $report(true, { - path: _path + "", - expected: "ICitizen", - value: input, - }))(input, "$input", true); - const success = 0 === errors.length; - return { - success, - errors, - data: success ? input : undefined, - } as any; - } - return { - success: true, - errors: [], - data: input, - } as any; - }; - return ( - input: string, - ): import("typia").IValidation> => - __validate(JSON.parse(input)) as any; -})(); diff --git a/test/generate/output/generate_misc.ts b/test/generate/output/generate_misc.ts index 882b5bdf74..e69de29bb2 100644 --- a/test/generate/output/generate_misc.ts +++ b/test/generate/output/generate_misc.ts @@ -1,1288 +0,0 @@ -import typia, { tags } from "typia"; -import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard.js"; -import * as __typia_transform__validateReport from "typia/lib/internal/_validateReport.js"; - -interface ICitizen { - id: string & tags.Format<"uuid">; - name: string & tags.Pattern<"^[A-Z][a-z]+$">; - email: string & tags.Format<"email">; - age: number & tags.Type<"uint32"> & tags.ExclusiveMaximum<100>; - motto: string; - birthdate: Date; - died_at: null | Date; - parent: ICitizen | null; - children: ICitizen[]; -} -export const createClone = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _co0 = (input: any): any => ({ - id: input.id, - name: input.name, - email: input.email, - age: input.age, - motto: input.motto, - birthdate: new Date(input.birthdate) as any, - died_at: input.died_at ? new Date(input.died_at) : (input.died_at as any), - parent: input.parent ? _co0(input.parent) : (input.parent as any), - children: _cp0(input.children) as any, - }); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - return (input: ICitizen): import("typia").Resolved => - _co0(input) as any; -})(); -export const createAssertClone = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _ao0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - (("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }, - _errorFactory, - )) && - (("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }, - _errorFactory, - )) && - (("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }, - _errorFactory, - )) && - (("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - }, - _errorFactory, - )) && - (input.age < 100 || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }, - _errorFactory, - )) && - ("string" === typeof input.motto || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".motto", - expected: "string", - value: input.motto, - }, - _errorFactory, - )) && - (input.birthdate instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }, - _errorFactory, - )) && - (null === input.died_at || - input.died_at instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }, - _errorFactory, - )) && - (null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - _ao0(input.parent, _path + ".parent", true && _exceptionable)) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - (((Array.isArray(input.children) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )) && - input.children.every( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - )) && - _ao0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - ), - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertClone", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )); - const _co0 = (input: any): any => ({ - id: input.id, - name: input.name, - email: input.email, - age: input.age, - motto: input.motto, - birthdate: new Date(input.birthdate) as any, - died_at: input.died_at ? new Date(input.died_at) : (input.died_at as any), - parent: input.parent ? _co0(input.parent) : (input.parent as any), - children: _cp0(input.children) as any, - }); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let _errorFactory: any; - const __assert = ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): ICitizen => { - if (false === __is(input)) { - _errorFactory = errorFactory; - ((input: any, _path: string, _exceptionable: boolean = true) => - ((("object" === typeof input && null !== input) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.misc.createAssertClone", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - )) && - _ao0(input, _path + "", true)) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.misc.createAssertClone", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - ))(input, "$input", true); - } - return input; - }; - const __clone = (input: ICitizen): import("typia").Resolved => - _co0(input) as any; - return ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): import("typia").Resolved => - __clone(__assert(input, errorFactory)); -})(); -export const createIsClone = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _co0 = (input: any): any => ({ - id: input.id, - name: input.name, - email: input.email, - age: input.age, - motto: input.motto, - birthdate: new Date(input.birthdate) as any, - died_at: input.died_at ? new Date(input.died_at) : (input.died_at as any), - parent: input.parent ? _co0(input.parent) : (input.parent as any), - children: _cp0(input.children) as any, - }); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - const __clone = (input: ICitizen): import("typia").Resolved => - _co0(input) as any; - return (input: any): import("typia").Resolved | null => { - if (!__is(input)) return null; - return __clone(input); - }; -})(); -export const createValidateClone = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _vo0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - [ - ("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - $report(_exceptionable, { - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }))) || - $report(_exceptionable, { - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }), - ("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - $report(_exceptionable, { - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }))) || - $report(_exceptionable, { - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }), - ("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - $report(_exceptionable, { - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }))) || - $report(_exceptionable, { - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }), - ("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - $report(_exceptionable, { - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - })) && - (input.age < 100 || - $report(_exceptionable, { - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }))) || - $report(_exceptionable, { - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }), - "string" === typeof input.motto || - $report(_exceptionable, { - path: _path + ".motto", - expected: "string", - value: input.motto, - }), - input.birthdate instanceof Date || - $report(_exceptionable, { - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }), - null === input.died_at || - input.died_at instanceof Date || - $report(_exceptionable, { - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }), - null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - })) && - _vo0(input.parent, _path + ".parent", true && _exceptionable)) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }), - ((Array.isArray(input.children) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - })) && - input.children - .map( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - })) && - _vo0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }), - ) - .every((flag: boolean) => flag)) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - }), - ].every((flag: boolean) => flag); - const _co0 = (input: any): any => ({ - id: input.id, - name: input.name, - email: input.email, - age: input.age, - motto: input.motto, - birthdate: new Date(input.birthdate) as any, - died_at: input.died_at ? new Date(input.died_at) : (input.died_at as any), - parent: input.parent ? _co0(input.parent) : (input.parent as any), - children: _cp0(input.children) as any, - }); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let errors: any; - let $report: any; - const __validate = (input: any): import("typia").IValidation => { - 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: "ICitizen", - value: input, - })) && - _vo0(input, _path + "", true)) || - $report(true, { - path: _path + "", - expected: "ICitizen", - value: input, - }))(input, "$input", true); - const success = 0 === errors.length; - return { - success, - errors, - data: success ? input : undefined, - } as any; - } - return { - success: true, - errors: [], - data: input, - } as any; - }; - const __clone = (input: ICitizen): import("typia").Resolved => - _co0(input) as any; - return ( - input: any, - ): import("typia").IValidation> => { - const result = __validate(input) as any; - if (result.success) result.data = __clone(input); - return result; - }; -})(); -export const createPrune = (() => { - const _pp0 = (input: any) => - input.forEach((elem: any) => { - if ("object" === typeof elem && null !== elem) _po0(elem); - }); - const _po0 = (input: any): any => { - if ("object" === typeof input.parent && null !== input.parent) - _po0(input.parent); - if (Array.isArray(input.children)) _pp0(input.children); - for (const key of Object.keys(input)) { - if ( - "id" === key || - "name" === key || - "email" === key || - "age" === key || - "motto" === key || - "birthdate" === key || - "died_at" === key || - "parent" === key || - "children" === key - ) - continue; - delete input[key]; - } - }; - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - return (input: ICitizen): void => { - if ("object" === typeof input && null !== input) _po0(input); - }; -})(); -export const createAssertPrune = (() => { - const _pp0 = (input: any) => - input.forEach((elem: any) => { - if ("object" === typeof elem && null !== elem) _po0(elem); - }); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _ao0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - (("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }, - _errorFactory, - )) && - (("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }, - _errorFactory, - )) && - (("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }, - _errorFactory, - )) && - (("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - }, - _errorFactory, - )) && - (input.age < 100 || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }, - _errorFactory, - )) && - ("string" === typeof input.motto || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".motto", - expected: "string", - value: input.motto, - }, - _errorFactory, - )) && - (input.birthdate instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }, - _errorFactory, - )) && - (null === input.died_at || - input.died_at instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }, - _errorFactory, - )) && - (null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - _ao0(input.parent, _path + ".parent", true && _exceptionable)) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - (((Array.isArray(input.children) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )) && - input.children.every( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - )) && - _ao0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - ), - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.misc.createAssertPrune", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )); - const _po0 = (input: any): any => { - if ("object" === typeof input.parent && null !== input.parent) - _po0(input.parent); - if (Array.isArray(input.children)) _pp0(input.children); - for (const key of Object.keys(input)) { - if ( - "id" === key || - "name" === key || - "email" === key || - "age" === key || - "motto" === key || - "birthdate" === key || - "died_at" === key || - "parent" === key || - "children" === key - ) - continue; - delete input[key]; - } - }; - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let _errorFactory: any; - const __assert = ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): ICitizen => { - if (false === __is(input)) { - _errorFactory = errorFactory; - ((input: any, _path: string, _exceptionable: boolean = true) => - ((("object" === typeof input && null !== input) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.misc.createAssertPrune", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - )) && - _ao0(input, _path + "", true)) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.misc.createAssertPrune", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - ))(input, "$input", true); - } - return input; - }; - const __prune = (input: ICitizen): void => { - if ("object" === typeof input && null !== input) _po0(input); - }; - return ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): ICitizen => { - input = __assert(input, errorFactory); - __prune(input); - return input; - }; -})(); -export const createIsPrune = (() => { - const _pp0 = (input: any) => - input.forEach((elem: any) => { - if ("object" === typeof elem && null !== elem) _po0(elem); - }); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _po0 = (input: any): any => { - if ("object" === typeof input.parent && null !== input.parent) - _po0(input.parent); - if (Array.isArray(input.children)) _pp0(input.children); - for (const key of Object.keys(input)) { - if ( - "id" === key || - "name" === key || - "email" === key || - "age" === key || - "motto" === key || - "birthdate" === key || - "died_at" === key || - "parent" === key || - "children" === key - ) - continue; - delete input[key]; - } - }; - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - const __prune = (input: ICitizen): void => { - if ("object" === typeof input && null !== input) _po0(input); - }; - return (input: any): input is ICitizen => { - if (false == __is(input)) return false; - __prune(input); - return true; - }; -})(); -export const createValidatePrune = (() => { - const _pp0 = (input: any) => - input.forEach((elem: any) => { - if ("object" === typeof elem && null !== elem) _po0(elem); - }); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _vo0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - [ - ("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - $report(_exceptionable, { - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }))) || - $report(_exceptionable, { - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }), - ("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - $report(_exceptionable, { - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }))) || - $report(_exceptionable, { - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }), - ("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - $report(_exceptionable, { - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }))) || - $report(_exceptionable, { - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }), - ("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - $report(_exceptionable, { - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - })) && - (input.age < 100 || - $report(_exceptionable, { - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }))) || - $report(_exceptionable, { - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }), - "string" === typeof input.motto || - $report(_exceptionable, { - path: _path + ".motto", - expected: "string", - value: input.motto, - }), - input.birthdate instanceof Date || - $report(_exceptionable, { - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }), - null === input.died_at || - input.died_at instanceof Date || - $report(_exceptionable, { - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }), - null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - })) && - _vo0(input.parent, _path + ".parent", true && _exceptionable)) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }), - ((Array.isArray(input.children) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - })) && - input.children - .map( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - })) && - _vo0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }), - ) - .every((flag: boolean) => flag)) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - }), - ].every((flag: boolean) => flag); - const _po0 = (input: any): any => { - if ("object" === typeof input.parent && null !== input.parent) - _po0(input.parent); - if (Array.isArray(input.children)) _pp0(input.children); - for (const key of Object.keys(input)) { - if ( - "id" === key || - "name" === key || - "email" === key || - "age" === key || - "motto" === key || - "birthdate" === key || - "died_at" === key || - "parent" === key || - "children" === key - ) - continue; - delete input[key]; - } - }; - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let errors: any; - let $report: any; - const __validate = (input: any): import("typia").IValidation => { - 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: "ICitizen", - value: input, - })) && - _vo0(input, _path + "", true)) || - $report(true, { - path: _path + "", - expected: "ICitizen", - value: input, - }))(input, "$input", true); - const success = 0 === errors.length; - return { - success, - errors, - data: success ? input : undefined, - } as any; - } - return { - success: true, - errors: [], - data: input, - } as any; - }; - const __prune = (input: ICitizen): void => { - if ("object" === typeof input && null !== input) _po0(input); - }; - return (input: any): import("typia").IValidation => { - const result = __validate(input); - if (result.success) __prune(input); - return result; - }; -})(); -export const literals = [false, 1, "two"] as const; diff --git a/test/generate/output/generate_notations.ts b/test/generate/output/generate_notations.ts index ba1b849808..e69de29bb2 100644 --- a/test/generate/output/generate_notations.ts +++ b/test/generate/output/generate_notations.ts @@ -1,1761 +0,0 @@ -import typia, { tags } from "typia"; -import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard.js"; -import * as __typia_transform__validateReport from "typia/lib/internal/_validateReport.js"; - -interface ICitizen { - id: string & tags.Format<"uuid">; - name: string & tags.Pattern<"^[A-Z][a-z]+$">; - email: string & tags.Format<"email">; - age: number & tags.Type<"uint32"> & tags.ExclusiveMaximum<100>; - motto: string; - birthdate: Date; - died_at: null | Date; - parent: ICitizen | null; - children: ICitizen[]; -} -export const createCamel = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _co0 = (input: any): any => ({ - id: input.id, - name: input.name, - email: input.email, - age: input.age, - motto: input.motto, - birthdate: new Date(input.birthdate) as any, - diedAt: input.died_at ? new Date(input.died_at) : (input.died_at as any), - parent: input.parent ? _co0(input.parent) : (input.parent as any), - children: _cp0(input.children) as any, - }); - return (input: ICitizen): import("typia").CamelCase => - _co0(input) as any; -})(); -export const createAssertCamel = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _ao0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - (("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }, - _errorFactory, - )) && - (("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }, - _errorFactory, - )) && - (("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }, - _errorFactory, - )) && - (("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - }, - _errorFactory, - )) && - (input.age < 100 || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }, - _errorFactory, - )) && - ("string" === typeof input.motto || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".motto", - expected: "string", - value: input.motto, - }, - _errorFactory, - )) && - (input.birthdate instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }, - _errorFactory, - )) && - (null === input.died_at || - input.died_at instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }, - _errorFactory, - )) && - (null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - _ao0(input.parent, _path + ".parent", true && _exceptionable)) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - (((Array.isArray(input.children) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )) && - input.children.every( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - )) && - _ao0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - ), - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertCamel", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )); - const _co0 = (input: any): any => ({ - id: input.id, - name: input.name, - email: input.email, - age: input.age, - motto: input.motto, - birthdate: new Date(input.birthdate) as any, - diedAt: input.died_at ? new Date(input.died_at) : (input.died_at as any), - parent: input.parent ? _co0(input.parent) : (input.parent as any), - children: _cp0(input.children) as any, - }); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let _errorFactory: any; - const __assert = ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): ICitizen => { - if (false === __is(input)) { - _errorFactory = errorFactory; - ((input: any, _path: string, _exceptionable: boolean = true) => - ((("object" === typeof input && null !== input) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.notations.createAssertCamel", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - )) && - _ao0(input, _path + "", true)) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.notations.createAssertCamel", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - ))(input, "$input", true); - } - return input; - }; - const __notation = (input: ICitizen): import("typia").CamelCase => - _co0(input) as any; - return ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): import("typia").CamelCase => - __notation(__assert(input, errorFactory)); -})(); -export const createIsCamel = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _co0 = (input: any): any => ({ - id: input.id, - name: input.name, - email: input.email, - age: input.age, - motto: input.motto, - birthdate: new Date(input.birthdate) as any, - diedAt: input.died_at ? new Date(input.died_at) : (input.died_at as any), - parent: input.parent ? _co0(input.parent) : (input.parent as any), - children: _cp0(input.children) as any, - }); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - const __notation = (input: ICitizen): import("typia").CamelCase => - _co0(input) as any; - return (input: any): import("typia").CamelCase | null => { - if (!__is(input)) return null; - return __notation(input); - }; -})(); -export const createValidateCamel = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _vo0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - [ - ("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - $report(_exceptionable, { - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }))) || - $report(_exceptionable, { - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }), - ("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - $report(_exceptionable, { - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }))) || - $report(_exceptionable, { - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }), - ("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - $report(_exceptionable, { - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }))) || - $report(_exceptionable, { - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }), - ("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - $report(_exceptionable, { - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - })) && - (input.age < 100 || - $report(_exceptionable, { - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }))) || - $report(_exceptionable, { - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }), - "string" === typeof input.motto || - $report(_exceptionable, { - path: _path + ".motto", - expected: "string", - value: input.motto, - }), - input.birthdate instanceof Date || - $report(_exceptionable, { - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }), - null === input.died_at || - input.died_at instanceof Date || - $report(_exceptionable, { - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }), - null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - })) && - _vo0(input.parent, _path + ".parent", true && _exceptionable)) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }), - ((Array.isArray(input.children) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - })) && - input.children - .map( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - })) && - _vo0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }), - ) - .every((flag: boolean) => flag)) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - }), - ].every((flag: boolean) => flag); - const _co0 = (input: any): any => ({ - id: input.id, - name: input.name, - email: input.email, - age: input.age, - motto: input.motto, - birthdate: new Date(input.birthdate) as any, - diedAt: input.died_at ? new Date(input.died_at) : (input.died_at as any), - parent: input.parent ? _co0(input.parent) : (input.parent as any), - children: _cp0(input.children) as any, - }); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let errors: any; - let $report: any; - const __validate = (input: any): import("typia").IValidation => { - 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: "ICitizen", - value: input, - })) && - _vo0(input, _path + "", true)) || - $report(true, { - path: _path + "", - expected: "ICitizen", - value: input, - }))(input, "$input", true); - const success = 0 === errors.length; - return { - success, - errors, - data: success ? input : undefined, - } as any; - } - return { - success: true, - errors: [], - data: input, - } as any; - }; - const __notation = (input: ICitizen): import("typia").CamelCase => - _co0(input) as any; - return ( - input: any, - ): import("typia").IValidation> => { - const result = __validate(input) as any; - if (result.success) result.data = __notation(input); - return result as any; - }; -})(); -export const createPascal = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _co0 = (input: any): any => ({ - Id: input.id, - Name: input.name, - Email: input.email, - Age: input.age, - Motto: input.motto, - Birthdate: new Date(input.birthdate) as any, - DiedAt: input.died_at ? new Date(input.died_at) : (input.died_at as any), - Parent: input.parent ? _co0(input.parent) : (input.parent as any), - Children: _cp0(input.children) as any, - }); - return (input: ICitizen): import("typia").PascalCase => - _co0(input) as any; -})(); -export const createAssertPascal = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _ao0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - (("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }, - _errorFactory, - )) && - (("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }, - _errorFactory, - )) && - (("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }, - _errorFactory, - )) && - (("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - }, - _errorFactory, - )) && - (input.age < 100 || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }, - _errorFactory, - )) && - ("string" === typeof input.motto || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".motto", - expected: "string", - value: input.motto, - }, - _errorFactory, - )) && - (input.birthdate instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }, - _errorFactory, - )) && - (null === input.died_at || - input.died_at instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }, - _errorFactory, - )) && - (null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - _ao0(input.parent, _path + ".parent", true && _exceptionable)) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - (((Array.isArray(input.children) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )) && - input.children.every( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - )) && - _ao0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - ), - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertPascal", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )); - const _co0 = (input: any): any => ({ - Id: input.id, - Name: input.name, - Email: input.email, - Age: input.age, - Motto: input.motto, - Birthdate: new Date(input.birthdate) as any, - DiedAt: input.died_at ? new Date(input.died_at) : (input.died_at as any), - Parent: input.parent ? _co0(input.parent) : (input.parent as any), - Children: _cp0(input.children) as any, - }); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let _errorFactory: any; - const __assert = ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): ICitizen => { - if (false === __is(input)) { - _errorFactory = errorFactory; - ((input: any, _path: string, _exceptionable: boolean = true) => - ((("object" === typeof input && null !== input) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.notations.createAssertPascal", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - )) && - _ao0(input, _path + "", true)) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.notations.createAssertPascal", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - ))(input, "$input", true); - } - return input; - }; - const __notation = (input: ICitizen): import("typia").PascalCase => - _co0(input) as any; - return ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): import("typia").PascalCase => - __notation(__assert(input, errorFactory)); -})(); -export const createIsPascal = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _co0 = (input: any): any => ({ - Id: input.id, - Name: input.name, - Email: input.email, - Age: input.age, - Motto: input.motto, - Birthdate: new Date(input.birthdate) as any, - DiedAt: input.died_at ? new Date(input.died_at) : (input.died_at as any), - Parent: input.parent ? _co0(input.parent) : (input.parent as any), - Children: _cp0(input.children) as any, - }); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - const __notation = (input: ICitizen): import("typia").PascalCase => - _co0(input) as any; - return (input: any): import("typia").PascalCase | null => { - if (!__is(input)) return null; - return __notation(input); - }; -})(); -export const createValidatePascal = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _vo0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - [ - ("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - $report(_exceptionable, { - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }))) || - $report(_exceptionable, { - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }), - ("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - $report(_exceptionable, { - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }))) || - $report(_exceptionable, { - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }), - ("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - $report(_exceptionable, { - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }))) || - $report(_exceptionable, { - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }), - ("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - $report(_exceptionable, { - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - })) && - (input.age < 100 || - $report(_exceptionable, { - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }))) || - $report(_exceptionable, { - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }), - "string" === typeof input.motto || - $report(_exceptionable, { - path: _path + ".motto", - expected: "string", - value: input.motto, - }), - input.birthdate instanceof Date || - $report(_exceptionable, { - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }), - null === input.died_at || - input.died_at instanceof Date || - $report(_exceptionable, { - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }), - null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - })) && - _vo0(input.parent, _path + ".parent", true && _exceptionable)) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }), - ((Array.isArray(input.children) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - })) && - input.children - .map( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - })) && - _vo0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }), - ) - .every((flag: boolean) => flag)) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - }), - ].every((flag: boolean) => flag); - const _co0 = (input: any): any => ({ - Id: input.id, - Name: input.name, - Email: input.email, - Age: input.age, - Motto: input.motto, - Birthdate: new Date(input.birthdate) as any, - DiedAt: input.died_at ? new Date(input.died_at) : (input.died_at as any), - Parent: input.parent ? _co0(input.parent) : (input.parent as any), - Children: _cp0(input.children) as any, - }); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let errors: any; - let $report: any; - const __validate = (input: any): import("typia").IValidation => { - 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: "ICitizen", - value: input, - })) && - _vo0(input, _path + "", true)) || - $report(true, { - path: _path + "", - expected: "ICitizen", - value: input, - }))(input, "$input", true); - const success = 0 === errors.length; - return { - success, - errors, - data: success ? input : undefined, - } as any; - } - return { - success: true, - errors: [], - data: input, - } as any; - }; - const __notation = (input: ICitizen): import("typia").PascalCase => - _co0(input) as any; - return ( - input: any, - ): import("typia").IValidation> => { - const result = __validate(input) as any; - if (result.success) result.data = __notation(input); - return result as any; - }; -})(); -export const createSnake = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _co0 = (input: any): any => ({ - id: input.id, - name: input.name, - email: input.email, - age: input.age, - motto: input.motto, - birthdate: new Date(input.birthdate) as any, - died_at: input.died_at ? new Date(input.died_at) : (input.died_at as any), - parent: input.parent ? _co0(input.parent) : (input.parent as any), - children: _cp0(input.children) as any, - }); - return (input: ICitizen): import("typia").SnakeCase => - _co0(input) as any; -})(); -export const createAssertSnake = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _ao0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - (("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }, - _errorFactory, - )) && - (("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }, - _errorFactory, - )) && - (("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }, - _errorFactory, - )) && - (("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - }, - _errorFactory, - )) && - (input.age < 100 || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }, - _errorFactory, - )) && - ("string" === typeof input.motto || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".motto", - expected: "string", - value: input.motto, - }, - _errorFactory, - )) && - (input.birthdate instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }, - _errorFactory, - )) && - (null === input.died_at || - input.died_at instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }, - _errorFactory, - )) && - (null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - _ao0(input.parent, _path + ".parent", true && _exceptionable)) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - (((Array.isArray(input.children) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )) && - input.children.every( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - )) && - _ao0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - ), - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.notations.createAssertSnake", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )); - const _co0 = (input: any): any => ({ - id: input.id, - name: input.name, - email: input.email, - age: input.age, - motto: input.motto, - birthdate: new Date(input.birthdate) as any, - died_at: input.died_at ? new Date(input.died_at) : (input.died_at as any), - parent: input.parent ? _co0(input.parent) : (input.parent as any), - children: _cp0(input.children) as any, - }); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let _errorFactory: any; - const __assert = ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): ICitizen => { - if (false === __is(input)) { - _errorFactory = errorFactory; - ((input: any, _path: string, _exceptionable: boolean = true) => - ((("object" === typeof input && null !== input) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.notations.createAssertSnake", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - )) && - _ao0(input, _path + "", true)) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.notations.createAssertSnake", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - ))(input, "$input", true); - } - return input; - }; - const __notation = (input: ICitizen): import("typia").SnakeCase => - _co0(input) as any; - return ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): import("typia").SnakeCase => - __notation(__assert(input, errorFactory)); -})(); -export const createIsSnake = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _co0 = (input: any): any => ({ - id: input.id, - name: input.name, - email: input.email, - age: input.age, - motto: input.motto, - birthdate: new Date(input.birthdate) as any, - died_at: input.died_at ? new Date(input.died_at) : (input.died_at as any), - parent: input.parent ? _co0(input.parent) : (input.parent as any), - children: _cp0(input.children) as any, - }); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - const __notation = (input: ICitizen): import("typia").SnakeCase => - _co0(input) as any; - return (input: any): import("typia").SnakeCase | null => { - if (!__is(input)) return null; - return __notation(input); - }; -})(); -export const createValidateSnake = (() => { - const _cp0 = (input: any) => input.map((elem: any) => _co0(elem) as any); - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _vo0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - [ - ("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - $report(_exceptionable, { - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }))) || - $report(_exceptionable, { - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }), - ("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - $report(_exceptionable, { - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }))) || - $report(_exceptionable, { - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }), - ("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - $report(_exceptionable, { - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }))) || - $report(_exceptionable, { - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }), - ("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - $report(_exceptionable, { - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - })) && - (input.age < 100 || - $report(_exceptionable, { - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }))) || - $report(_exceptionable, { - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }), - "string" === typeof input.motto || - $report(_exceptionable, { - path: _path + ".motto", - expected: "string", - value: input.motto, - }), - input.birthdate instanceof Date || - $report(_exceptionable, { - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }), - null === input.died_at || - input.died_at instanceof Date || - $report(_exceptionable, { - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }), - null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - })) && - _vo0(input.parent, _path + ".parent", true && _exceptionable)) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }), - ((Array.isArray(input.children) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - })) && - input.children - .map( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - })) && - _vo0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }), - ) - .every((flag: boolean) => flag)) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - }), - ].every((flag: boolean) => flag); - const _co0 = (input: any): any => ({ - id: input.id, - name: input.name, - email: input.email, - age: input.age, - motto: input.motto, - birthdate: new Date(input.birthdate) as any, - died_at: input.died_at ? new Date(input.died_at) : (input.died_at as any), - parent: input.parent ? _co0(input.parent) : (input.parent as any), - children: _cp0(input.children) as any, - }); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let errors: any; - let $report: any; - const __validate = (input: any): import("typia").IValidation => { - 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: "ICitizen", - value: input, - })) && - _vo0(input, _path + "", true)) || - $report(true, { - path: _path + "", - expected: "ICitizen", - value: input, - }))(input, "$input", true); - const success = 0 === errors.length; - return { - success, - errors, - data: success ? input : undefined, - } as any; - } - return { - success: true, - errors: [], - data: input, - } as any; - }; - const __notation = (input: ICitizen): import("typia").SnakeCase => - _co0(input) as any; - return ( - input: any, - ): import("typia").IValidation> => { - const result = __validate(input) as any; - if (result.success) result.data = __notation(input); - return result as any; - }; -})(); diff --git a/test/generate/output/generate_plain.ts b/test/generate/output/generate_plain.ts index 4c37b54824..e69de29bb2 100644 --- a/test/generate/output/generate_plain.ts +++ b/test/generate/output/generate_plain.ts @@ -1,1860 +0,0 @@ -import typia, { tags } from "typia"; -import * as __typia_transform__accessExpressionAsString from "typia/lib/internal/_accessExpressionAsString.js"; -import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard.js"; -import * as __typia_transform__randomArray from "typia/lib/internal/_randomArray.js"; -import * as __typia_transform__randomFormatDatetime from "typia/lib/internal/_randomFormatDatetime.js"; -import * as __typia_transform__randomFormatEmail from "typia/lib/internal/_randomFormatEmail.js"; -import * as __typia_transform__randomFormatUuid from "typia/lib/internal/_randomFormatUuid.js"; -import * as __typia_transform__randomInteger from "typia/lib/internal/_randomInteger.js"; -import * as __typia_transform__randomPattern from "typia/lib/internal/_randomPattern.js"; -import * as __typia_transform__randomPick from "typia/lib/internal/_randomPick.js"; -import * as __typia_transform__randomString from "typia/lib/internal/_randomString.js"; -import * as __typia_transform__validateReport from "typia/lib/internal/_validateReport.js"; - -interface ICitizen { - id: string & tags.Format<"uuid">; - name: string & tags.Pattern<"^[A-Z][a-z]+$">; - email: string & tags.Format<"email">; - age: number & tags.Type<"uint32"> & tags.ExclusiveMaximum<100>; - motto: string; - birthdate: Date; - died_at: null | Date; - parent: ICitizen | null; - children: ICitizen[]; -} -export const createIs = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - return (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); -})(); -export const createEquals = (() => { - const _io0 = (input: any, _exceptionable: boolean = true): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent, true && _exceptionable))) && - Array.isArray(input.children) && - input.children.every( - (elem: any, _index1: number) => - "object" === typeof elem && - null !== elem && - _io0(elem, true && _exceptionable), - ) && - (9 === Object.keys(input).length || - Object.keys(input).every((key: any) => { - if ( - [ - "id", - "name", - "email", - "age", - "motto", - "birthdate", - "died_at", - "parent", - "children", - ].some((prop: any) => key === prop) - ) - return true; - const value = input[key]; - if (undefined === value) return true; - return false; - })); - return (input: any, _exceptionable: boolean = true): input is ICitizen => - "object" === typeof input && null !== input && _io0(input, true); -})(); -export const createAssert = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _ao0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - (("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }, - _errorFactory, - )) && - (("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }, - _errorFactory, - )) && - (("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }, - _errorFactory, - )) && - (("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - }, - _errorFactory, - )) && - (input.age < 100 || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }, - _errorFactory, - )) && - ("string" === typeof input.motto || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".motto", - expected: "string", - value: input.motto, - }, - _errorFactory, - )) && - (input.birthdate instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }, - _errorFactory, - )) && - (null === input.died_at || - input.died_at instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }, - _errorFactory, - )) && - (null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - _ao0(input.parent, _path + ".parent", true && _exceptionable)) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - (((Array.isArray(input.children) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )) && - input.children.every( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - )) && - _ao0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - ), - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssert", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let _errorFactory: any; - return ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): ICitizen => { - if (false === __is(input)) { - _errorFactory = errorFactory; - ((input: any, _path: string, _exceptionable: boolean = true) => - ((("object" === typeof input && null !== input) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.createAssert", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - )) && - _ao0(input, _path + "", true)) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.createAssert", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - ))(input, "$input", true); - } - return input; - }; -})(); -export const createAssertEquals = (() => { - const _io0 = (input: any, _exceptionable: boolean = true): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent, true && _exceptionable))) && - Array.isArray(input.children) && - input.children.every( - (elem: any, _index1: number) => - "object" === typeof elem && - null !== elem && - _io0(elem, true && _exceptionable), - ) && - (9 === Object.keys(input).length || - Object.keys(input).every((key: any) => { - if ( - [ - "id", - "name", - "email", - "age", - "motto", - "birthdate", - "died_at", - "parent", - "children", - ].some((prop: any) => key === prop) - ) - return true; - const value = input[key]; - if (undefined === value) return true; - return false; - })); - const _ao0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - (("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }, - _errorFactory, - )) && - (("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }, - _errorFactory, - )) && - (("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }, - _errorFactory, - )) && - (("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - }, - _errorFactory, - )) && - (input.age < 100 || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }, - _errorFactory, - )) && - ("string" === typeof input.motto || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".motto", - expected: "string", - value: input.motto, - }, - _errorFactory, - )) && - (input.birthdate instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }, - _errorFactory, - )) && - (null === input.died_at || - input.died_at instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }, - _errorFactory, - )) && - (null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - _ao0(input.parent, _path + ".parent", true && _exceptionable)) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - (((Array.isArray(input.children) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )) && - input.children.every( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - )) && - _ao0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - ), - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )) && - (9 === Object.keys(input).length || - false === _exceptionable || - Object.keys(input).every((key: any) => { - if ( - [ - "id", - "name", - "email", - "age", - "motto", - "birthdate", - "died_at", - "parent", - "children", - ].some((prop: any) => key === prop) - ) - return true; - const value = input[key]; - if (undefined === value) return true; - return __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertEquals", - path: - _path + - __typia_transform__accessExpressionAsString._accessExpressionAsString( - key, - ), - expected: "undefined", - value: value, - }, - _errorFactory, - ); - })); - const __is = ( - input: any, - _exceptionable: boolean = true, - ): input is ICitizen => - "object" === typeof input && null !== input && _io0(input, true); - let _errorFactory: any; - return ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): ICitizen => { - if (false === __is(input)) { - _errorFactory = errorFactory; - ((input: any, _path: string, _exceptionable: boolean = true) => - ((("object" === typeof input && null !== input) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.createAssertEquals", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - )) && - _ao0(input, _path + "", true)) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.createAssertEquals", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - ))(input, "$input", true); - } - return input; - }; -})(); -export const createAssertGuard = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _ao0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - (("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }, - _errorFactory, - )) && - (("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }, - _errorFactory, - )) && - (("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }, - _errorFactory, - )) && - (("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - }, - _errorFactory, - )) && - (input.age < 100 || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }, - _errorFactory, - )) && - ("string" === typeof input.motto || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".motto", - expected: "string", - value: input.motto, - }, - _errorFactory, - )) && - (input.birthdate instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }, - _errorFactory, - )) && - (null === input.died_at || - input.died_at instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }, - _errorFactory, - )) && - (null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - _ao0(input.parent, _path + ".parent", true && _exceptionable)) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - (((Array.isArray(input.children) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )) && - input.children.every( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - )) && - _ao0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - ), - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuard", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let _errorFactory: any; - return ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): asserts input is ICitizen => { - if (false === __is(input)) { - _errorFactory = errorFactory; - ((input: any, _path: string, _exceptionable: boolean = true) => - ((("object" === typeof input && null !== input) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.createAssertGuard", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - )) && - _ao0(input, _path + "", true)) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.createAssertGuard", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - ))(input, "$input", true); - } - }; -})(); -export const createAssertGuardEquals = (() => { - const _io0 = (input: any, _exceptionable: boolean = true): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent, true && _exceptionable))) && - Array.isArray(input.children) && - input.children.every( - (elem: any, _index1: number) => - "object" === typeof elem && - null !== elem && - _io0(elem, true && _exceptionable), - ) && - (9 === Object.keys(input).length || - Object.keys(input).every((key: any) => { - if ( - [ - "id", - "name", - "email", - "age", - "motto", - "birthdate", - "died_at", - "parent", - "children", - ].some((prop: any) => key === prop) - ) - return true; - const value = input[key]; - if (undefined === value) return true; - return false; - })); - const _ao0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - (("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }, - _errorFactory, - )) && - (("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }, - _errorFactory, - )) && - (("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }, - _errorFactory, - )) && - (("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - }, - _errorFactory, - )) && - (input.age < 100 || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }, - _errorFactory, - )) && - ("string" === typeof input.motto || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".motto", - expected: "string", - value: input.motto, - }, - _errorFactory, - )) && - (input.birthdate instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }, - _errorFactory, - )) && - (null === input.died_at || - input.died_at instanceof Date || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }, - _errorFactory, - )) && - (null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - _ao0(input.parent, _path + ".parent", true && _exceptionable)) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }, - _errorFactory, - )) && - (((Array.isArray(input.children) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )) && - input.children.every( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - )) && - _ao0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }, - _errorFactory, - ), - )) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: _path + ".children", - expected: "Array", - value: input.children, - }, - _errorFactory, - )) && - (9 === Object.keys(input).length || - false === _exceptionable || - Object.keys(input).every((key: any) => { - if ( - [ - "id", - "name", - "email", - "age", - "motto", - "birthdate", - "died_at", - "parent", - "children", - ].some((prop: any) => key === prop) - ) - return true; - const value = input[key]; - if (undefined === value) return true; - return __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.createAssertGuardEquals", - path: - _path + - __typia_transform__accessExpressionAsString._accessExpressionAsString( - key, - ), - expected: "undefined", - value: value, - }, - _errorFactory, - ); - })); - const __is = ( - input: any, - _exceptionable: boolean = true, - ): input is ICitizen => - "object" === typeof input && null !== input && _io0(input, true); - let _errorFactory: any; - return ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): asserts input is ICitizen => { - if (false === __is(input)) { - _errorFactory = errorFactory; - ((input: any, _path: string, _exceptionable: boolean = true) => - ((("object" === typeof input && null !== input) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.createAssertGuardEquals", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - )) && - _ao0(input, _path + "", true)) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.createAssertGuardEquals", - path: _path + "", - expected: "ICitizen", - value: input, - }, - _errorFactory, - ))(input, "$input", true); - } - }; -})(); -export const createValidate = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent))) && - Array.isArray(input.children) && - input.children.every( - (elem: any) => "object" === typeof elem && null !== elem && _io0(elem), - ); - const _vo0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - [ - ("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - $report(_exceptionable, { - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }))) || - $report(_exceptionable, { - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }), - ("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - $report(_exceptionable, { - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }))) || - $report(_exceptionable, { - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }), - ("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - $report(_exceptionable, { - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }))) || - $report(_exceptionable, { - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }), - ("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - $report(_exceptionable, { - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - })) && - (input.age < 100 || - $report(_exceptionable, { - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }))) || - $report(_exceptionable, { - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }), - "string" === typeof input.motto || - $report(_exceptionable, { - path: _path + ".motto", - expected: "string", - value: input.motto, - }), - input.birthdate instanceof Date || - $report(_exceptionable, { - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }), - null === input.died_at || - input.died_at instanceof Date || - $report(_exceptionable, { - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }), - null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - })) && - _vo0(input.parent, _path + ".parent", true && _exceptionable)) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }), - ((Array.isArray(input.children) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - })) && - input.children - .map( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - })) && - _vo0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }), - ) - .every((flag: boolean) => flag)) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - }), - ].every((flag: boolean) => flag); - const __is = (input: any): input is ICitizen => - "object" === typeof input && null !== input && _io0(input); - let errors: any; - let $report: any; - return (input: any): import("typia").IValidation => { - 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: "ICitizen", - value: input, - })) && - _vo0(input, _path + "", true)) || - $report(true, { - path: _path + "", - expected: "ICitizen", - value: input, - }))(input, "$input", true); - const success = 0 === errors.length; - return { - success, - errors, - data: success ? input : undefined, - } as any; - } - return { - success: true, - errors: [], - data: input, - } as any; - }; -})(); -export const createValidateEquals = (() => { - const _io0 = (input: any, _exceptionable: boolean = true): boolean => - "string" === typeof input.id && - /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) && - "string" === typeof input.name && - RegExp("^[A-Z][a-z]+$").test(input.name) && - "string" === typeof input.email && - /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) && - "number" === typeof input.age && - Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295 && - input.age < 100 && - "string" === typeof input.motto && - input.birthdate instanceof Date && - (null === input.died_at || input.died_at instanceof Date) && - (null === input.parent || - ("object" === typeof input.parent && - null !== input.parent && - _io0(input.parent, true && _exceptionable))) && - Array.isArray(input.children) && - input.children.every( - (elem: any, _index1: number) => - "object" === typeof elem && - null !== elem && - _io0(elem, true && _exceptionable), - ) && - (9 === Object.keys(input).length || - Object.keys(input).every((key: any) => { - if ( - [ - "id", - "name", - "email", - "age", - "motto", - "birthdate", - "died_at", - "parent", - "children", - ].some((prop: any) => key === prop) - ) - return true; - const value = input[key]; - if (undefined === value) return true; - return false; - })); - const _vo0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - [ - ("string" === typeof input.id && - (/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test( - input.id, - ) || - $report(_exceptionable, { - path: _path + ".id", - expected: 'string & Format<"uuid">', - value: input.id, - }))) || - $report(_exceptionable, { - path: _path + ".id", - expected: '(string & Format<"uuid">)', - value: input.id, - }), - ("string" === typeof input.name && - (RegExp("^[A-Z][a-z]+$").test(input.name) || - $report(_exceptionable, { - path: _path + ".name", - expected: 'string & Pattern<"^[A-Z][a-z]+$">', - value: input.name, - }))) || - $report(_exceptionable, { - path: _path + ".name", - expected: '(string & Pattern<"^[A-Z][a-z]+$">)', - value: input.name, - }), - ("string" === typeof input.email && - (/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test( - input.email, - ) || - $report(_exceptionable, { - path: _path + ".email", - expected: 'string & Format<"email">', - value: input.email, - }))) || - $report(_exceptionable, { - path: _path + ".email", - expected: '(string & Format<"email">)', - value: input.email, - }), - ("number" === typeof input.age && - ((Math.floor(input.age) === input.age && - 0 <= input.age && - input.age <= 4294967295) || - $report(_exceptionable, { - path: _path + ".age", - expected: 'number & Type<"uint32">', - value: input.age, - })) && - (input.age < 100 || - $report(_exceptionable, { - path: _path + ".age", - expected: "number & ExclusiveMaximum<100>", - value: input.age, - }))) || - $report(_exceptionable, { - path: _path + ".age", - expected: '(number & Type<"uint32"> & ExclusiveMaximum<100>)', - value: input.age, - }), - "string" === typeof input.motto || - $report(_exceptionable, { - path: _path + ".motto", - expected: "string", - value: input.motto, - }), - input.birthdate instanceof Date || - $report(_exceptionable, { - path: _path + ".birthdate", - expected: "Date", - value: input.birthdate, - }), - null === input.died_at || - input.died_at instanceof Date || - $report(_exceptionable, { - path: _path + ".died_at", - expected: "(Date | null)", - value: input.died_at, - }), - null === input.parent || - ((("object" === typeof input.parent && null !== input.parent) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - })) && - _vo0(input.parent, _path + ".parent", true && _exceptionable)) || - $report(_exceptionable, { - path: _path + ".parent", - expected: "(ICitizen | null)", - value: input.parent, - }), - ((Array.isArray(input.children) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - })) && - input.children - .map( - (elem: any, _index2: number) => - ((("object" === typeof elem && null !== elem) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - })) && - _vo0( - elem, - _path + ".children[" + _index2 + "]", - true && _exceptionable, - )) || - $report(_exceptionable, { - path: _path + ".children[" + _index2 + "]", - expected: "ICitizen", - value: elem, - }), - ) - .every((flag: boolean) => flag)) || - $report(_exceptionable, { - path: _path + ".children", - expected: "Array", - value: input.children, - }), - 9 === Object.keys(input).length || - false === _exceptionable || - Object.keys(input) - .map((key: any) => { - if ( - [ - "id", - "name", - "email", - "age", - "motto", - "birthdate", - "died_at", - "parent", - "children", - ].some((prop: any) => key === prop) - ) - return true; - const value = input[key]; - if (undefined === value) return true; - return $report(_exceptionable, { - path: - _path + - __typia_transform__accessExpressionAsString._accessExpressionAsString( - key, - ), - expected: "undefined", - value: value, - }); - }) - .every((flag: boolean) => flag), - ].every((flag: boolean) => flag); - const __is = ( - input: any, - _exceptionable: boolean = true, - ): input is ICitizen => - "object" === typeof input && null !== input && _io0(input, true); - let errors: any; - let $report: any; - return (input: any): import("typia").IValidation => { - 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: "ICitizen", - value: input, - })) && - _vo0(input, _path + "", true)) || - $report(true, { - path: _path + "", - expected: "ICitizen", - value: input, - }))(input, "$input", true); - const success = 0 === errors.length; - return { - success, - errors, - data: success ? input : undefined, - } as any; - } - return { - success: true, - errors: [], - data: input, - } as any; - }; -})(); -export const createRandom = (() => { - const _ro0 = (_recursive: boolean = true, _depth: number = 0): any => ({ - id: ( - _generator?.uuid ?? __typia_transform__randomFormatUuid._randomFormatUuid - )(), - name: ( - _generator?.pattern ?? __typia_transform__randomPattern._randomPattern - )(new RegExp("^[A-Z][a-z]+$")), - email: ( - _generator?.email ?? - __typia_transform__randomFormatEmail._randomFormatEmail - )(), - age: ( - _generator?.integer ?? __typia_transform__randomInteger._randomInteger - )({ - type: "integer", - exclusiveMaximum: true, - maximum: 100, - }), - motto: ( - _generator?.string ?? __typia_transform__randomString._randomString - )({ - type: "string", - }), - birthdate: new Date( - ( - _generator?.datetime ?? - __typia_transform__randomFormatDatetime._randomFormatDatetime - )(), - ), - died_at: __typia_transform__randomPick._randomPick([ - () => null, - () => - new Date( - ( - _generator?.datetime ?? - __typia_transform__randomFormatDatetime._randomFormatDatetime - )(), - ), - ])(), - parent: __typia_transform__randomPick._randomPick([ - () => null, - () => _ro0(true, _recursive ? 1 + _depth : _depth), - ])(), - children: - 5 >= _depth - ? (_generator?.array ?? __typia_transform__randomArray._randomArray)({ - type: "array", - element: () => _ro0(true, _recursive ? 1 + _depth : _depth), - }) - : [], - }); - let _generator: Partial | undefined; - return ( - generator?: Partial, - ): import("typia").Resolved => { - _generator = generator; - return _ro0(); - }; -})(); diff --git a/test/generate/output/generate_protobuf.ts b/test/generate/output/generate_protobuf.ts index ee3fde35a3..e69de29bb2 100644 --- a/test/generate/output/generate_protobuf.ts +++ b/test/generate/output/generate_protobuf.ts @@ -1,915 +0,0 @@ -import typia, { tags } from "typia"; -import * as __typia_transform__ProtobufReader from "typia/lib/internal/_ProtobufReader.js"; -import * as __typia_transform__ProtobufSizer from "typia/lib/internal/_ProtobufSizer.js"; -import * as __typia_transform__ProtobufWriter from "typia/lib/internal/_ProtobufWriter.js"; -import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard.js"; -import * as __typia_transform__validateReport from "typia/lib/internal/_validateReport.js"; - -interface IFile { - name: string & tags.MaxLength<8>; - extension: null | (string & tags.MinLength<1> & tags.MaxLength<3>); - size: number & tags.Type<"uint32">; - data: Uint8Array; -} -export const createEncode = (() => { - const encoder = < - Writer extends - import("typia/lib/internal/_IProtobufWriter.js")._IProtobufWriter, - >( - writer: Writer, - input: any, - ): Writer => { - const _peo0 = (input: any): any => { - // property "name": (string & MaxLength<8>); - writer.uint32(10); - writer.string(input.name); - // property "extension": ((string & MinLength<1> & MaxLength<3>) | null); - if (null !== input.extension) { - writer.uint32(18); - writer.string(input.extension); - } - // property "size": (number & Type<"uint32">); - writer.uint32(24); - writer.uint32(input.size); - // property "data": Uint8Array; - writer.uint32(34); - writer.bytes(input.data); - }; - _peo0(input); - return writer; - }; - return (input: IFile): Uint8Array => { - const sizer = encoder( - new __typia_transform__ProtobufSizer._ProtobufSizer(), - input, - ); - const writer = encoder( - new __typia_transform__ProtobufWriter._ProtobufWriter(sizer), - input, - ); - return writer.buffer(); - }; -})(); -export const createAssertEncode = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.name && - input.name.length <= 8 && - (null === input.extension || - ("string" === typeof input.extension && - 1 <= input.extension.length && - input.extension.length <= 3)) && - "number" === typeof input.size && - Math.floor(input.size) === input.size && - 0 <= input.size && - input.size <= 4294967295 && - input.data instanceof Uint8Array; - const _ao0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - (("string" === typeof input.name && - (input.name.length <= 8 || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertEncode", - path: _path + ".name", - expected: "string & MaxLength<8>", - value: input.name, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertEncode", - path: _path + ".name", - expected: "(string & MaxLength<8>)", - value: input.name, - }, - _errorFactory, - )) && - (null === input.extension || - ("string" === typeof input.extension && - (1 <= input.extension.length || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertEncode", - path: _path + ".extension", - expected: "string & MinLength<1>", - value: input.extension, - }, - _errorFactory, - )) && - (input.extension.length <= 3 || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertEncode", - path: _path + ".extension", - expected: "string & MaxLength<3>", - value: input.extension, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertEncode", - path: _path + ".extension", - expected: "((string & MinLength<1> & MaxLength<3>) | null)", - value: input.extension, - }, - _errorFactory, - )) && - (("number" === typeof input.size && - ((Math.floor(input.size) === input.size && - 0 <= input.size && - input.size <= 4294967295) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertEncode", - path: _path + ".size", - expected: 'number & Type<"uint32">', - value: input.size, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertEncode", - path: _path + ".size", - expected: '(number & Type<"uint32">)', - value: input.size, - }, - _errorFactory, - )) && - (input.data instanceof Uint8Array || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertEncode", - path: _path + ".data", - expected: "Uint8Array", - value: input.data, - }, - _errorFactory, - )); - const encoder = < - Writer extends - import("typia/lib/internal/_IProtobufWriter.js")._IProtobufWriter, - >( - writer: Writer, - input: any, - ): Writer => { - const _peo0 = (input: any): any => { - // property "name": (string & MaxLength<8>); - writer.uint32(10); - writer.string(input.name); - // property "extension": ((string & MinLength<1> & MaxLength<3>) | null); - if (null !== input.extension) { - writer.uint32(18); - writer.string(input.extension); - } - // property "size": (number & Type<"uint32">); - writer.uint32(24); - writer.uint32(input.size); - // property "data": Uint8Array; - writer.uint32(34); - writer.bytes(input.data); - }; - const _io0 = (input: any): boolean => - "string" === typeof input.name && - input.name.length <= 8 && - (null === input.extension || - ("string" === typeof input.extension && - 1 <= input.extension.length && - input.extension.length <= 3)) && - "number" === typeof input.size && - Math.floor(input.size) === input.size && - 0 <= input.size && - input.size <= 4294967295 && - input.data instanceof Uint8Array; - _peo0(input); - return writer; - }; - const __is = (input: any): input is IFile => - "object" === typeof input && null !== input && _io0(input); - let _errorFactory: any; - const __assert = ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): IFile => { - if (false === __is(input)) { - _errorFactory = errorFactory; - ((input: any, _path: string, _exceptionable: boolean = true) => - ((("object" === typeof input && null !== input) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.protobuf.createAssertEncode", - path: _path + "", - expected: "IFile", - value: input, - }, - _errorFactory, - )) && - _ao0(input, _path + "", true)) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.protobuf.createAssertEncode", - path: _path + "", - expected: "IFile", - value: input, - }, - _errorFactory, - ))(input, "$input", true); - } - return input; - }; - const __encode = (input: IFile): Uint8Array => { - const sizer = encoder( - new __typia_transform__ProtobufSizer._ProtobufSizer(), - input, - ); - const writer = encoder( - new __typia_transform__ProtobufWriter._ProtobufWriter(sizer), - input, - ); - return writer.buffer(); - }; - return ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): Uint8Array => __encode(__assert(input, errorFactory)); -})(); -export const createIsEncode = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.name && - input.name.length <= 8 && - (null === input.extension || - ("string" === typeof input.extension && - 1 <= input.extension.length && - input.extension.length <= 3)) && - "number" === typeof input.size && - Math.floor(input.size) === input.size && - 0 <= input.size && - input.size <= 4294967295 && - input.data instanceof Uint8Array; - const encoder = < - Writer extends - import("typia/lib/internal/_IProtobufWriter.js")._IProtobufWriter, - >( - writer: Writer, - input: any, - ): Writer => { - const _peo0 = (input: any): any => { - // property "name": (string & MaxLength<8>); - writer.uint32(10); - writer.string(input.name); - // property "extension": ((string & MinLength<1> & MaxLength<3>) | null); - if (null !== input.extension) { - writer.uint32(18); - writer.string(input.extension); - } - // property "size": (number & Type<"uint32">); - writer.uint32(24); - writer.uint32(input.size); - // property "data": Uint8Array; - writer.uint32(34); - writer.bytes(input.data); - }; - const _io0 = (input: any): boolean => - "string" === typeof input.name && - input.name.length <= 8 && - (null === input.extension || - ("string" === typeof input.extension && - 1 <= input.extension.length && - input.extension.length <= 3)) && - "number" === typeof input.size && - Math.floor(input.size) === input.size && - 0 <= input.size && - input.size <= 4294967295 && - input.data instanceof Uint8Array; - _peo0(input); - return writer; - }; - const __is = (input: any): input is IFile => - "object" === typeof input && null !== input && _io0(input); - const __encode = (input: IFile): Uint8Array => { - const sizer = encoder( - new __typia_transform__ProtobufSizer._ProtobufSizer(), - input, - ); - const writer = encoder( - new __typia_transform__ProtobufWriter._ProtobufWriter(sizer), - input, - ); - return writer.buffer(); - }; - return (input: any): Uint8Array | null => - __is(input) ? __encode(input) : null; -})(); -export const createValidateEncode = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.name && - input.name.length <= 8 && - (null === input.extension || - ("string" === typeof input.extension && - 1 <= input.extension.length && - input.extension.length <= 3)) && - "number" === typeof input.size && - Math.floor(input.size) === input.size && - 0 <= input.size && - input.size <= 4294967295 && - input.data instanceof Uint8Array; - const _vo0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - [ - ("string" === typeof input.name && - (input.name.length <= 8 || - $report(_exceptionable, { - path: _path + ".name", - expected: "string & MaxLength<8>", - value: input.name, - }))) || - $report(_exceptionable, { - path: _path + ".name", - expected: "(string & MaxLength<8>)", - value: input.name, - }), - null === input.extension || - ("string" === typeof input.extension && - (1 <= input.extension.length || - $report(_exceptionable, { - path: _path + ".extension", - expected: "string & MinLength<1>", - value: input.extension, - })) && - (input.extension.length <= 3 || - $report(_exceptionable, { - path: _path + ".extension", - expected: "string & MaxLength<3>", - value: input.extension, - }))) || - $report(_exceptionable, { - path: _path + ".extension", - expected: "((string & MinLength<1> & MaxLength<3>) | null)", - value: input.extension, - }), - ("number" === typeof input.size && - ((Math.floor(input.size) === input.size && - 0 <= input.size && - input.size <= 4294967295) || - $report(_exceptionable, { - path: _path + ".size", - expected: 'number & Type<"uint32">', - value: input.size, - }))) || - $report(_exceptionable, { - path: _path + ".size", - expected: '(number & Type<"uint32">)', - value: input.size, - }), - input.data instanceof Uint8Array || - $report(_exceptionable, { - path: _path + ".data", - expected: "Uint8Array", - value: input.data, - }), - ].every((flag: boolean) => flag); - const encoder = < - Writer extends - import("typia/lib/internal/_IProtobufWriter.js")._IProtobufWriter, - >( - writer: Writer, - input: any, - ): Writer => { - const _peo0 = (input: any): any => { - // property "name": (string & MaxLength<8>); - writer.uint32(10); - writer.string(input.name); - // property "extension": ((string & MinLength<1> & MaxLength<3>) | null); - if (null !== input.extension) { - writer.uint32(18); - writer.string(input.extension); - } - // property "size": (number & Type<"uint32">); - writer.uint32(24); - writer.uint32(input.size); - // property "data": Uint8Array; - writer.uint32(34); - writer.bytes(input.data); - }; - const _io0 = (input: any): boolean => - "string" === typeof input.name && - input.name.length <= 8 && - (null === input.extension || - ("string" === typeof input.extension && - 1 <= input.extension.length && - input.extension.length <= 3)) && - "number" === typeof input.size && - Math.floor(input.size) === input.size && - 0 <= input.size && - input.size <= 4294967295 && - input.data instanceof Uint8Array; - _peo0(input); - return writer; - }; - const __is = (input: any): input is IFile => - "object" === typeof input && null !== input && _io0(input); - let errors: any; - let $report: any; - const __validate = (input: any): import("typia").IValidation => { - 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: "IFile", - value: input, - })) && - _vo0(input, _path + "", true)) || - $report(true, { - path: _path + "", - expected: "IFile", - value: input, - }))(input, "$input", true); - const success = 0 === errors.length; - return { - success, - errors, - data: success ? input : undefined, - } as any; - } - return { - success: true, - errors: [], - data: input, - } as any; - }; - const __encode = (input: IFile): Uint8Array => { - const sizer = encoder( - new __typia_transform__ProtobufSizer._ProtobufSizer(), - input, - ); - const writer = encoder( - new __typia_transform__ProtobufWriter._ProtobufWriter(sizer), - input, - ); - return writer.buffer(); - }; - return (input: any): import("typia").IValidation => { - const result = __validate(input) as any; - if (result.success) result.data = __encode(input); - return result; - }; -})(); -export const createDecode = (() => { - const _pdo0 = (reader: any, length: number = -1): any => { - length = length < 0 ? reader.size() : reader.index() + length; - const output = { - name: "" as any, - extension: null as any, - size: undefined as any, - data: new Uint8Array([]) as any, - } as any; - while (reader.index() < length) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - // string; - output.name = reader.string(); - break; - case 2: - // string; - output.extension = reader.string(); - break; - case 3: - // uint32; - output.size = reader.uint32(); - break; - case 4: - // bytes; - output.data = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return output; - }; - return (input: Uint8Array): import("typia").Resolved => { - const reader = new __typia_transform__ProtobufReader._ProtobufReader(input); - return _pdo0(reader); - }; -})(); -export const createAssertDecode = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.name && - input.name.length <= 8 && - (null === input.extension || - ("string" === typeof input.extension && - 1 <= input.extension.length && - input.extension.length <= 3)) && - "number" === typeof input.size && - Math.floor(input.size) === input.size && - 0 <= input.size && - input.size <= 4294967295 && - input.data instanceof Uint8Array; - const _ao0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - (("string" === typeof input.name && - (input.name.length <= 8 || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertDecode", - path: _path + ".name", - expected: "string & MaxLength<8>", - value: input.name, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertDecode", - path: _path + ".name", - expected: "(string & MaxLength<8>)", - value: input.name, - }, - _errorFactory, - )) && - (null === input.extension || - ("string" === typeof input.extension && - (1 <= input.extension.length || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertDecode", - path: _path + ".extension", - expected: "string & MinLength<1>", - value: input.extension, - }, - _errorFactory, - )) && - (input.extension.length <= 3 || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertDecode", - path: _path + ".extension", - expected: "string & MaxLength<3>", - value: input.extension, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertDecode", - path: _path + ".extension", - expected: "((string & MinLength<1> & MaxLength<3>) | null)", - value: input.extension, - }, - _errorFactory, - )) && - (("number" === typeof input.size && - ((Math.floor(input.size) === input.size && - 0 <= input.size && - input.size <= 4294967295) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertDecode", - path: _path + ".size", - expected: 'number & Type<"uint32">', - value: input.size, - }, - _errorFactory, - ))) || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertDecode", - path: _path + ".size", - expected: '(number & Type<"uint32">)', - value: input.size, - }, - _errorFactory, - )) && - (input.data instanceof Uint8Array || - __typia_transform__assertGuard._assertGuard( - _exceptionable, - { - method: "typia.protobuf.createAssertDecode", - path: _path + ".data", - expected: "Uint8Array", - value: input.data, - }, - _errorFactory, - )); - const _pdo0 = (reader: any, length: number = -1): any => { - length = length < 0 ? reader.size() : reader.index() + length; - const output = { - name: "" as any, - extension: null as any, - size: undefined as any, - data: new Uint8Array([]) as any, - } as any; - while (reader.index() < length) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - // string; - output.name = reader.string(); - break; - case 2: - // string; - output.extension = reader.string(); - break; - case 3: - // uint32; - output.size = reader.uint32(); - break; - case 4: - // bytes; - output.data = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return output; - }; - const __is = (input: any): input is IFile => - "object" === typeof input && null !== input && _io0(input); - let _errorFactory: any; - const __assert = ( - input: any, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): IFile => { - if (false === __is(input)) { - _errorFactory = errorFactory; - ((input: any, _path: string, _exceptionable: boolean = true) => - ((("object" === typeof input && null !== input) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.protobuf.createAssertDecode", - path: _path + "", - expected: "IFile", - value: input, - }, - _errorFactory, - )) && - _ao0(input, _path + "", true)) || - __typia_transform__assertGuard._assertGuard( - true, - { - method: "typia.protobuf.createAssertDecode", - path: _path + "", - expected: "IFile", - value: input, - }, - _errorFactory, - ))(input, "$input", true); - } - return input; - }; - const __decode = (input: Uint8Array): import("typia").Resolved => { - const reader = new __typia_transform__ProtobufReader._ProtobufReader(input); - return _pdo0(reader); - }; - return ( - input: Uint8Array, - errorFactory?: (p: import("typia").TypeGuardError.IProps) => Error, - ): import("typia").Resolved => __assert(__decode(input), errorFactory); -})(); -export const createIsDecode = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.name && - input.name.length <= 8 && - (null === input.extension || - ("string" === typeof input.extension && - 1 <= input.extension.length && - input.extension.length <= 3)) && - "number" === typeof input.size && - Math.floor(input.size) === input.size && - 0 <= input.size && - input.size <= 4294967295 && - input.data instanceof Uint8Array; - const _pdo0 = (reader: any, length: number = -1): any => { - length = length < 0 ? reader.size() : reader.index() + length; - const output = { - name: "" as any, - extension: null as any, - size: undefined as any, - data: new Uint8Array([]) as any, - } as any; - while (reader.index() < length) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - // string; - output.name = reader.string(); - break; - case 2: - // string; - output.extension = reader.string(); - break; - case 3: - // uint32; - output.size = reader.uint32(); - break; - case 4: - // bytes; - output.data = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return output; - }; - const __is = (input: any): input is IFile => - "object" === typeof input && null !== input && _io0(input); - const __decode = (input: Uint8Array): import("typia").Resolved => { - const reader = new __typia_transform__ProtobufReader._ProtobufReader(input); - return _pdo0(reader); - }; - return (input: Uint8Array): import("typia").Resolved | null => { - const value = __decode(input); - if (!__is(value)) return null; - return value; - }; -})(); -export const createValidateDecode = (() => { - const _io0 = (input: any): boolean => - "string" === typeof input.name && - input.name.length <= 8 && - (null === input.extension || - ("string" === typeof input.extension && - 1 <= input.extension.length && - input.extension.length <= 3)) && - "number" === typeof input.size && - Math.floor(input.size) === input.size && - 0 <= input.size && - input.size <= 4294967295 && - input.data instanceof Uint8Array; - const _vo0 = ( - input: any, - _path: string, - _exceptionable: boolean = true, - ): boolean => - [ - ("string" === typeof input.name && - (input.name.length <= 8 || - $report(_exceptionable, { - path: _path + ".name", - expected: "string & MaxLength<8>", - value: input.name, - }))) || - $report(_exceptionable, { - path: _path + ".name", - expected: "(string & MaxLength<8>)", - value: input.name, - }), - null === input.extension || - ("string" === typeof input.extension && - (1 <= input.extension.length || - $report(_exceptionable, { - path: _path + ".extension", - expected: "string & MinLength<1>", - value: input.extension, - })) && - (input.extension.length <= 3 || - $report(_exceptionable, { - path: _path + ".extension", - expected: "string & MaxLength<3>", - value: input.extension, - }))) || - $report(_exceptionable, { - path: _path + ".extension", - expected: "((string & MinLength<1> & MaxLength<3>) | null)", - value: input.extension, - }), - ("number" === typeof input.size && - ((Math.floor(input.size) === input.size && - 0 <= input.size && - input.size <= 4294967295) || - $report(_exceptionable, { - path: _path + ".size", - expected: 'number & Type<"uint32">', - value: input.size, - }))) || - $report(_exceptionable, { - path: _path + ".size", - expected: '(number & Type<"uint32">)', - value: input.size, - }), - input.data instanceof Uint8Array || - $report(_exceptionable, { - path: _path + ".data", - expected: "Uint8Array", - value: input.data, - }), - ].every((flag: boolean) => flag); - const _pdo0 = (reader: any, length: number = -1): any => { - length = length < 0 ? reader.size() : reader.index() + length; - const output = { - name: "" as any, - extension: null as any, - size: undefined as any, - data: new Uint8Array([]) as any, - } as any; - while (reader.index() < length) { - const tag = reader.uint32(); - switch (tag >>> 3) { - case 1: - // string; - output.name = reader.string(); - break; - case 2: - // string; - output.extension = reader.string(); - break; - case 3: - // uint32; - output.size = reader.uint32(); - break; - case 4: - // bytes; - output.data = reader.bytes(); - break; - default: - reader.skipType(tag & 7); - break; - } - } - return output; - }; - const __is = (input: any): input is IFile => - "object" === typeof input && null !== input && _io0(input); - let errors: any; - let $report: any; - const __validate = (input: any): import("typia").IValidation => { - 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: "IFile", - value: input, - })) && - _vo0(input, _path + "", true)) || - $report(true, { - path: _path + "", - expected: "IFile", - value: input, - }))(input, "$input", true); - const success = 0 === errors.length; - return { - success, - errors, - data: success ? input : undefined, - } as any; - } - return { - success: true, - errors: [], - data: input, - } as any; - }; - const __decode = (input: Uint8Array): import("typia").Resolved => { - const reader = new __typia_transform__ProtobufReader._ProtobufReader(input); - return _pdo0(reader); - }; - return ( - input: Uint8Array, - ): import("typia").IValidation> => - __validate(__decode(input)); -})(); diff --git a/test/package.json b/test/package.json index 9c0c192b32..b827e32f0e 100644 --- a/test/package.json +++ b/test/package.json @@ -53,6 +53,6 @@ "suppress-warnings": "^1.0.2", "tstl": "^3.0.0", "uuid": "^9.0.1", - "typia": "../typia-7.0.0-dev.20241112.tgz" + "typia": "../typia-7.0.0-dev.20241114.tgz" } } \ No newline at end of file diff --git a/test/schemas/reflect/metadata/ArraySimpleProtobuf.json b/test/schemas/reflect/metadata/ArraySimpleProtobuf.json index fbf2fd5575..e1ff56fde7 100644 --- a/test/schemas/reflect/metadata/ArraySimpleProtobuf.json +++ b/test/schemas/reflect/metadata/ArraySimpleProtobuf.json @@ -661,7 +661,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -707,7 +707,7 @@ "name": "Type<\"uint32\">", "kind": "type", "value": "uint32", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 4294967295", + "validate": "$importInternal(\"isTypeUint32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -845,7 +845,7 @@ "name": "Type<\"float\">", "kind": "type", "value": "float", - "validate": "-1.175494351e38 <= $input && $input <= 3.4028235e38", + "validate": "$importInternal(\"isTypeFloat\")($input)", "exclusive": true, "schema": { "type": "number" diff --git a/test/schemas/reflect/metadata/ArraySimpleProtobufNullable.json b/test/schemas/reflect/metadata/ArraySimpleProtobufNullable.json index 8513603e92..9dd23047e5 100644 --- a/test/schemas/reflect/metadata/ArraySimpleProtobufNullable.json +++ b/test/schemas/reflect/metadata/ArraySimpleProtobufNullable.json @@ -661,7 +661,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -707,7 +707,7 @@ "name": "Type<\"uint32\">", "kind": "type", "value": "uint32", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 4294967295", + "validate": "$importInternal(\"isTypeUint32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -845,7 +845,7 @@ "name": "Type<\"float\">", "kind": "type", "value": "float", - "validate": "-1.175494351e38 <= $input && $input <= 3.4028235e38", + "validate": "$importInternal(\"isTypeFloat\")($input)", "exclusive": true, "schema": { "type": "number" diff --git a/test/schemas/reflect/metadata/ArraySimpleProtobufOptional.json b/test/schemas/reflect/metadata/ArraySimpleProtobufOptional.json index 17f76726b0..7b017d90c5 100644 --- a/test/schemas/reflect/metadata/ArraySimpleProtobufOptional.json +++ b/test/schemas/reflect/metadata/ArraySimpleProtobufOptional.json @@ -661,7 +661,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -707,7 +707,7 @@ "name": "Type<\"uint32\">", "kind": "type", "value": "uint32", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 4294967295", + "validate": "$importInternal(\"isTypeUint32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -845,7 +845,7 @@ "name": "Type<\"float\">", "kind": "type", "value": "float", - "validate": "-1.175494351e38 <= $input && $input <= 3.4028235e38", + "validate": "$importInternal(\"isTypeFloat\")($input)", "exclusive": true, "schema": { "type": "number" diff --git a/test/schemas/reflect/metadata/ConstantAtomicTagged.json b/test/schemas/reflect/metadata/ConstantAtomicTagged.json index 57da0623e8..44a736c3a5 100644 --- a/test/schemas/reflect/metadata/ConstantAtomicTagged.json +++ b/test/schemas/reflect/metadata/ConstantAtomicTagged.json @@ -76,7 +76,7 @@ "name": "Format<\"uuid\">", "kind": "format", "value": "uuid", - "validate": "/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test($input)", + "validate": "$importInternal(\"isFormatUuid\")($input)", "exclusive": [ "format", "pattern" @@ -160,7 +160,7 @@ "name": "Type<\"uint32\">", "kind": "type", "value": "uint32", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 4294967295", + "validate": "$importInternal(\"isTypeUint32\")($input)", "exclusive": true, "schema": { "type": "integer" diff --git a/test/schemas/reflect/metadata/DynamicTag.json b/test/schemas/reflect/metadata/DynamicTag.json index 51c331e224..2f81aa66d4 100644 --- a/test/schemas/reflect/metadata/DynamicTag.json +++ b/test/schemas/reflect/metadata/DynamicTag.json @@ -145,7 +145,7 @@ "name": "Format<\"uuid\">", "kind": "format", "value": "uuid", - "validate": "/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test($input)", + "validate": "$importInternal(\"isFormatUuid\")($input)", "exclusive": [ "format", "pattern" @@ -186,7 +186,7 @@ "name": "Format<\"email\">", "kind": "format", "value": "email", - "validate": "/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test($input)", + "validate": "$importInternal(\"isFormatEmail\")($input)", "exclusive": [ "format", "pattern" diff --git a/test/schemas/reflect/metadata/MapSimpleProtobuf.json b/test/schemas/reflect/metadata/MapSimpleProtobuf.json index eae8ad4e5d..0a3ba2f243 100644 --- a/test/schemas/reflect/metadata/MapSimpleProtobuf.json +++ b/test/schemas/reflect/metadata/MapSimpleProtobuf.json @@ -223,7 +223,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" diff --git a/test/schemas/reflect/metadata/MapSimpleProtobufNullable.json b/test/schemas/reflect/metadata/MapSimpleProtobufNullable.json index 61b953e777..37f3e7eb32 100644 --- a/test/schemas/reflect/metadata/MapSimpleProtobufNullable.json +++ b/test/schemas/reflect/metadata/MapSimpleProtobufNullable.json @@ -223,7 +223,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" diff --git a/test/schemas/reflect/metadata/MapSimpleProtobufOptional.json b/test/schemas/reflect/metadata/MapSimpleProtobufOptional.json index 33e1ea0acd..d7f6352b28 100644 --- a/test/schemas/reflect/metadata/MapSimpleProtobufOptional.json +++ b/test/schemas/reflect/metadata/MapSimpleProtobufOptional.json @@ -223,7 +223,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" diff --git a/test/schemas/reflect/metadata/ObjectDate.json b/test/schemas/reflect/metadata/ObjectDate.json index e3ab0b0f27..97dcbcea65 100644 --- a/test/schemas/reflect/metadata/ObjectDate.json +++ b/test/schemas/reflect/metadata/ObjectDate.json @@ -177,7 +177,7 @@ "name": "Format<\"date\">", "kind": "format", "value": "date", - "validate": "/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test($input)", + "validate": "$importInternal(\"isFormatDate\")($input)", "exclusive": [ "format", "pattern" @@ -251,7 +251,7 @@ "name": "Format<\"date-time\">", "kind": "format", "value": "date-time", - "validate": "/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(T|\\s)([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i.test($input)", + "validate": "$importInternal(\"isFormatDateTime\")($input)", "exclusive": [ "format", "pattern" @@ -325,7 +325,7 @@ "name": "Format<\"time\">", "kind": "format", "value": "time", - "validate": "/^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i.test($input)", + "validate": "$importInternal(\"isFormatTime\")($input)", "exclusive": [ "format", "pattern" @@ -399,7 +399,7 @@ "name": "Format<\"duration\">", "kind": "format", "value": "duration", - "validate": "/^P(?!$)((\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+S)?)?|(\\d+W)?)$/.test($input)", + "validate": "$importInternal(\"isFormatDuration\")($input)", "exclusive": [ "format", "pattern" diff --git a/test/schemas/reflect/metadata/ObjectDescription.json b/test/schemas/reflect/metadata/ObjectDescription.json index 4183502b4d..c0fbcd3d93 100644 --- a/test/schemas/reflect/metadata/ObjectDescription.json +++ b/test/schemas/reflect/metadata/ObjectDescription.json @@ -76,7 +76,7 @@ "name": "Format<\"uuid\">", "kind": "format", "value": "uuid", - "validate": "/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test($input)", + "validate": "$importInternal(\"isFormatUuid\")($input)", "exclusive": [ "format", "pattern" diff --git a/test/schemas/reflect/metadata/ObjectHttpFormData.json b/test/schemas/reflect/metadata/ObjectHttpFormData.json index 04de6219f1..6c9d42309b 100644 --- a/test/schemas/reflect/metadata/ObjectHttpFormData.json +++ b/test/schemas/reflect/metadata/ObjectHttpFormData.json @@ -76,7 +76,7 @@ "name": "Format<\"uuid\">", "kind": "format", "value": "uuid", - "validate": "/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test($input)", + "validate": "$importInternal(\"isFormatUuid\")($input)", "exclusive": [ "format", "pattern" @@ -475,7 +475,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" diff --git a/test/schemas/reflect/metadata/ObjectHttpTypeTag.json b/test/schemas/reflect/metadata/ObjectHttpTypeTag.json index 7ed9ba67e9..22467f4bff 100644 --- a/test/schemas/reflect/metadata/ObjectHttpTypeTag.json +++ b/test/schemas/reflect/metadata/ObjectHttpTypeTag.json @@ -76,7 +76,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -218,7 +218,7 @@ "name": "Format<\"uuid\">", "kind": "format", "value": "uuid", - "validate": "/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test($input)", + "validate": "$importInternal(\"isFormatUuid\")($input)", "exclusive": [ "format", "pattern" diff --git a/test/schemas/reflect/metadata/ObjectSequenceProtobuf.json b/test/schemas/reflect/metadata/ObjectSequenceProtobuf.json index 571679b167..a1c844ced6 100644 --- a/test/schemas/reflect/metadata/ObjectSequenceProtobuf.json +++ b/test/schemas/reflect/metadata/ObjectSequenceProtobuf.json @@ -162,7 +162,7 @@ "name": "Type<\"uint64\">", "kind": "type", "value": "uint64", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 18446744073709551615", + "validate": "$importInternal(\"isTypeUint64\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -518,7 +518,7 @@ "name": "Format<\"uri\">", "kind": "format", "value": "uri", - "validate": "/\\/|:/.test($input) && /^(?:[a-z][a-z0-9+\\-.]*:)(?:\\/?\\/(?:(?:[a-z0-9\\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\\.[a-z0-9\\-._~!$&'()*+,;=:]+)\\]|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)|(?:[a-z0-9\\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\\d*)?(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\\/(?:(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\\?(?:[a-z0-9\\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i.test($input)", + "validate": "$importInternal(\"isFormatUri\")($input)", "exclusive": [ "format", "pattern" @@ -606,7 +606,7 @@ "name": "Format<\"email\">", "kind": "format", "value": "email", - "validate": "/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test($input)", + "validate": "$importInternal(\"isFormatEmail\")($input)", "exclusive": [ "format", "pattern" @@ -748,7 +748,7 @@ "name": "Format<\"uuid\">", "kind": "format", "value": "uuid", - "validate": "/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test($input)", + "validate": "$importInternal(\"isFormatUuid\")($input)", "exclusive": [ "format", "pattern" diff --git a/test/schemas/reflect/metadata/ObjectSimpleProtobuf.json b/test/schemas/reflect/metadata/ObjectSimpleProtobuf.json index d4c41ade13..3cd8a7d522 100644 --- a/test/schemas/reflect/metadata/ObjectSimpleProtobuf.json +++ b/test/schemas/reflect/metadata/ObjectSimpleProtobuf.json @@ -133,7 +133,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -204,7 +204,7 @@ "name": "Type<\"uint32\">", "kind": "type", "value": "uint32", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 4294967295", + "validate": "$importInternal(\"isTypeUint32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -403,7 +403,7 @@ "name": "Type<\"float\">", "kind": "type", "value": "float", - "validate": "-1.175494351e38 <= $input && $input <= 3.4028235e38", + "validate": "$importInternal(\"isTypeFloat\")($input)", "exclusive": true, "schema": { "type": "number" diff --git a/test/schemas/reflect/metadata/ObjectSimpleProtobufNullable.json b/test/schemas/reflect/metadata/ObjectSimpleProtobufNullable.json index 6fc74bc98e..6de08d26c6 100644 --- a/test/schemas/reflect/metadata/ObjectSimpleProtobufNullable.json +++ b/test/schemas/reflect/metadata/ObjectSimpleProtobufNullable.json @@ -133,7 +133,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -204,7 +204,7 @@ "name": "Type<\"uint32\">", "kind": "type", "value": "uint32", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 4294967295", + "validate": "$importInternal(\"isTypeUint32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -403,7 +403,7 @@ "name": "Type<\"float\">", "kind": "type", "value": "float", - "validate": "-1.175494351e38 <= $input && $input <= 3.4028235e38", + "validate": "$importInternal(\"isTypeFloat\")($input)", "exclusive": true, "schema": { "type": "number" diff --git a/test/schemas/reflect/metadata/ObjectSimpleProtobufOptional.json b/test/schemas/reflect/metadata/ObjectSimpleProtobufOptional.json index e3c54c2773..48e5fda0ac 100644 --- a/test/schemas/reflect/metadata/ObjectSimpleProtobufOptional.json +++ b/test/schemas/reflect/metadata/ObjectSimpleProtobufOptional.json @@ -133,7 +133,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -204,7 +204,7 @@ "name": "Type<\"uint32\">", "kind": "type", "value": "uint32", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 4294967295", + "validate": "$importInternal(\"isTypeUint32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -403,7 +403,7 @@ "name": "Type<\"float\">", "kind": "type", "value": "float", - "validate": "-1.175494351e38 <= $input && $input <= 3.4028235e38", + "validate": "$importInternal(\"isTypeFloat\")($input)", "exclusive": true, "schema": { "type": "number" diff --git a/test/schemas/reflect/metadata/TypeTagArray.json b/test/schemas/reflect/metadata/TypeTagArray.json index 6e5c40c126..b34a5583a9 100644 --- a/test/schemas/reflect/metadata/TypeTagArray.json +++ b/test/schemas/reflect/metadata/TypeTagArray.json @@ -547,7 +547,7 @@ "name": "Format<\"uuid\">", "kind": "format", "value": "uuid", - "validate": "/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test($input)", + "validate": "$importInternal(\"isFormatUuid\")($input)", "exclusive": [ "format", "pattern" diff --git a/test/schemas/reflect/metadata/TypeTagArrayUnion.json b/test/schemas/reflect/metadata/TypeTagArrayUnion.json index fe453e6bbf..b3b9a81043 100644 --- a/test/schemas/reflect/metadata/TypeTagArrayUnion.json +++ b/test/schemas/reflect/metadata/TypeTagArrayUnion.json @@ -397,7 +397,7 @@ "name": "Format<\"uuid\">", "kind": "format", "value": "uuid", - "validate": "/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test($input)", + "validate": "$importInternal(\"isFormatUuid\")($input)", "exclusive": [ "format", "pattern" diff --git a/test/schemas/reflect/metadata/TypeTagCustom.json b/test/schemas/reflect/metadata/TypeTagCustom.json index d9d9e2880e..2340bfbac2 100644 --- a/test/schemas/reflect/metadata/TypeTagCustom.json +++ b/test/schemas/reflect/metadata/TypeTagCustom.json @@ -76,7 +76,7 @@ "name": "Format<\"uuid\">", "kind": "format", "value": "uuid", - "validate": "/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test($input)", + "validate": "$importInternal(\"isFormatUuid\")($input)", "exclusive": [ "format", "pattern" diff --git a/test/schemas/reflect/metadata/TypeTagFormat.json b/test/schemas/reflect/metadata/TypeTagFormat.json index 89a767a8d3..d1801dca5b 100644 --- a/test/schemas/reflect/metadata/TypeTagFormat.json +++ b/test/schemas/reflect/metadata/TypeTagFormat.json @@ -76,7 +76,7 @@ "name": "Format<\"byte\">", "kind": "format", "value": "byte", - "validate": "/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm.test($input)", + "validate": "$importInternal(\"isFormatByte\")($input)", "exclusive": [ "format", "pattern" @@ -150,7 +150,7 @@ "name": "Format<\"password\">", "kind": "format", "value": "password", - "validate": "true", + "validate": "$importInternal(\"isFormatPassword\")($input)", "exclusive": [ "format", "pattern" @@ -224,7 +224,7 @@ "name": "Format<\"regex\">", "kind": "format", "value": "regex", - "validate": "(() => { try { new RegExp($input); return true; } catch { return false; } })()", + "validate": "$importInternal(\"isFormatRegex\")($input)", "exclusive": [ "format", "pattern" @@ -298,7 +298,7 @@ "name": "Format<\"uuid\">", "kind": "format", "value": "uuid", - "validate": "/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test($input)", + "validate": "$importInternal(\"isFormatUuid\")($input)", "exclusive": [ "format", "pattern" @@ -372,7 +372,7 @@ "name": "Format<\"email\">", "kind": "format", "value": "email", - "validate": "/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test($input)", + "validate": "$importInternal(\"isFormatEmail\")($input)", "exclusive": [ "format", "pattern" @@ -446,7 +446,7 @@ "name": "Format<\"hostname\">", "kind": "format", "value": "hostname", - "validate": "/^(?=.{1,253}\\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\\.?$/i.test($input)", + "validate": "$importInternal(\"isFormatHostname\")($input)", "exclusive": [ "format", "pattern" @@ -520,7 +520,7 @@ "name": "Format<\"idn-email\">", "kind": "format", "value": "idn-email", - "validate": "/^(([^<>()[\\]\\.,;:\\s@\\\"]+(\\.[^<>()[\\]\\.,;:\\s@\\\"]+)*)|(\\\".+\\\"))@(([^<>()[\\]\\.,;:\\s@\\\"]+\\.)+[^<>()[\\]\\.,;:\\s@\\\"]{2,})$/i.test($input)", + "validate": "$importInternal(\"isFormatIdnEmail\")($input)", "exclusive": [ "format", "pattern" @@ -594,7 +594,7 @@ "name": "Format<\"idn-hostname\">", "kind": "format", "value": "idn-hostname", - "validate": "/^([a-z0-9\\u00a1-\\uffff0-9]+(-[a-z0-9\\u00a1-\\uffff0-9]+)*\\.)+[a-z\\u00a1-\\uffff]{2,}$/i.test($input)", + "validate": "$importInternal(\"isFormatIdnHostname\")($input)", "exclusive": [ "format", "pattern" @@ -668,7 +668,7 @@ "name": "Format<\"iri\">", "kind": "format", "value": "iri", - "validate": "/^[A-Za-z][\\d+-.A-Za-z]*:[^\\u0000-\\u0020\"<>\\\\^`{|}]*$/u.test($input)", + "validate": "$importInternal(\"isFormatIri\")($input)", "exclusive": [ "format", "pattern" @@ -742,7 +742,7 @@ "name": "Format<\"iri-reference\">", "kind": "format", "value": "iri-reference", - "validate": "/^[A-Za-z][\\d+-.A-Za-z]*:[^\\u0000-\\u0020\"<>\\\\^`{|}]*$/u.test($input)", + "validate": "$importInternal(\"isFormatIriReference\")($input)", "exclusive": [ "format", "pattern" @@ -816,7 +816,7 @@ "name": "Format<\"ipv4\">", "kind": "format", "value": "ipv4", - "validate": "/^(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)$/.test($input)", + "validate": "$importInternal(\"isFormatIpv4\")($input)", "exclusive": [ "format", "pattern" @@ -890,7 +890,7 @@ "name": "Format<\"ipv6\">", "kind": "format", "value": "ipv6", - "validate": "/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]d|1dd|[1-9]?d)(.(25[0-5]|2[0-4]d|1dd|[1-9]?d)){3}))|:)))$/i.test($input)", + "validate": "$importInternal(\"isFormatIpv6\")($input)", "exclusive": [ "format", "pattern" @@ -964,7 +964,7 @@ "name": "Format<\"uri\">", "kind": "format", "value": "uri", - "validate": "/\\/|:/.test($input) && /^(?:[a-z][a-z0-9+\\-.]*:)(?:\\/?\\/(?:(?:[a-z0-9\\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\\.[a-z0-9\\-._~!$&'()*+,;=:]+)\\]|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)|(?:[a-z0-9\\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\\d*)?(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\\/(?:(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\\?(?:[a-z0-9\\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i.test($input)", + "validate": "$importInternal(\"isFormatUri\")($input)", "exclusive": [ "format", "pattern" @@ -1038,7 +1038,7 @@ "name": "Format<\"uri-reference\">", "kind": "format", "value": "uri-reference", - "validate": "/^(?:[a-z][a-z0-9+\\-.]*:)?(?:\\/?\\/(?:(?:[a-z0-9\\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\\.[a-z0-9\\-._~!$&'()*+,;=:]+)\\]|(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)|(?:[a-z0-9\\-._~!$&'\"()*+,;=]|%[0-9a-f]{2})*)(?::\\d*)?(?:\\/(?:[a-z0-9\\-._~!$&'\"()*+,;=:@]|%[0-9a-f]{2})*)*|\\/(?:(?:[a-z0-9\\-._~!$&'\"()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'\"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\\-._~!$&'\"()*+,;=:@]|%[0-9a-f]{2})+(?:\\/(?:[a-z0-9\\-._~!$&'\"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\\?(?:[a-z0-9\\-._~!$&'\"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\\-._~!$&'\"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i.test($input)", + "validate": "$importInternal(\"isFormatUriReference\")($input)", "exclusive": [ "format", "pattern" @@ -1112,7 +1112,7 @@ "name": "Format<\"uri-template\">", "kind": "format", "value": "uri-template", - "validate": "/^(?:(?:[^\\x00-\\x20\"'<>%\\\\^`{|}]|%[0-9a-f]{2})|\\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\\*)?)*\\})*$/i.test($input)", + "validate": "$importInternal(\"isFormatUriTemplate\")($input)", "exclusive": [ "format", "pattern" @@ -1186,7 +1186,7 @@ "name": "Format<\"url\">", "kind": "format", "value": "url", - "validate": "/^(?:https?|ftp):\\/\\/(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z0-9\\u{00a1}-\\u{ffff}]+-)*[a-z0-9\\u{00a1}-\\u{ffff}]+)(?:\\.(?:[a-z0-9\\u{00a1}-\\u{ffff}]+-)*[a-z0-9\\u{00a1}-\\u{ffff}]+)*(?:\\.(?:[a-z\\u{00a1}-\\u{ffff}]{2,})))(?::\\d{2,5})?(?:\\/[^\\s]*)?$/iu.test($input)", + "validate": "$importInternal(\"isFormatUrl\")($input)", "exclusive": [ "format", "pattern" @@ -1260,7 +1260,7 @@ "name": "Format<\"date-time\">", "kind": "format", "value": "date-time", - "validate": "/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(T|\\s)([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i.test($input)", + "validate": "$importInternal(\"isFormatDateTime\")($input)", "exclusive": [ "format", "pattern" @@ -1334,7 +1334,7 @@ "name": "Format<\"date\">", "kind": "format", "value": "date", - "validate": "/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test($input)", + "validate": "$importInternal(\"isFormatDate\")($input)", "exclusive": [ "format", "pattern" @@ -1408,7 +1408,7 @@ "name": "Format<\"time\">", "kind": "format", "value": "time", - "validate": "/^([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](?:\\.[0-9]{1,9})?(Z|[+-]([01][0-9]|2[0-3]):[0-5][0-9])$/i.test($input)", + "validate": "$importInternal(\"isFormatTime\")($input)", "exclusive": [ "format", "pattern" @@ -1482,7 +1482,7 @@ "name": "Format<\"duration\">", "kind": "format", "value": "duration", - "validate": "/^P(?!$)((\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+S)?)?|(\\d+W)?)$/.test($input)", + "validate": "$importInternal(\"isFormatDuration\")($input)", "exclusive": [ "format", "pattern" @@ -1556,7 +1556,7 @@ "name": "Format<\"json-pointer\">", "kind": "format", "value": "json-pointer", - "validate": "/^(?:\\/(?:[^~/]|~0|~1)*)*$/.test($input)", + "validate": "$importInternal(\"isFormatJsonPointer\")($input)", "exclusive": [ "format", "pattern" @@ -1630,7 +1630,7 @@ "name": "Format<\"relative-json-pointer\">", "kind": "format", "value": "relative-json-pointer", - "validate": "/^(?:0|[1-9][0-9]*)(?:#|(?:\\/(?:[^~/]|~0|~1)*)*)$/.test($input)", + "validate": "$importInternal(\"isFormatRelativeJsonPointer\")($input)", "exclusive": [ "format", "pattern" diff --git a/test/schemas/reflect/metadata/TypeTagInfinite.json b/test/schemas/reflect/metadata/TypeTagInfinite.json index 707b56223e..1202e2fd9b 100644 --- a/test/schemas/reflect/metadata/TypeTagInfinite.json +++ b/test/schemas/reflect/metadata/TypeTagInfinite.json @@ -440,7 +440,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" diff --git a/test/schemas/reflect/metadata/TypeTagMatrix.json b/test/schemas/reflect/metadata/TypeTagMatrix.json index 0027651797..7e86ead681 100644 --- a/test/schemas/reflect/metadata/TypeTagMatrix.json +++ b/test/schemas/reflect/metadata/TypeTagMatrix.json @@ -198,7 +198,7 @@ "name": "Format<\"uuid\">", "kind": "format", "value": "uuid", - "validate": "/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i.test($input)", + "validate": "$importInternal(\"isFormatUuid\")($input)", "exclusive": [ "format", "pattern" diff --git a/test/schemas/reflect/metadata/TypeTagNaN.json b/test/schemas/reflect/metadata/TypeTagNaN.json index 4d3724e059..3cd16fc46e 100644 --- a/test/schemas/reflect/metadata/TypeTagNaN.json +++ b/test/schemas/reflect/metadata/TypeTagNaN.json @@ -440,7 +440,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" diff --git a/test/schemas/reflect/metadata/TypeTagRange.json b/test/schemas/reflect/metadata/TypeTagRange.json index 7263c48034..0d6ff9293c 100644 --- a/test/schemas/reflect/metadata/TypeTagRange.json +++ b/test/schemas/reflect/metadata/TypeTagRange.json @@ -144,7 +144,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -230,7 +230,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -315,7 +315,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -401,7 +401,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -486,7 +486,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -587,7 +587,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -687,7 +687,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -787,7 +787,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -886,7 +886,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" diff --git a/test/schemas/reflect/metadata/TypeTagType.json b/test/schemas/reflect/metadata/TypeTagType.json index b28c3c64cc..4b661fac85 100644 --- a/test/schemas/reflect/metadata/TypeTagType.json +++ b/test/schemas/reflect/metadata/TypeTagType.json @@ -144,7 +144,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -215,7 +215,7 @@ "name": "Type<\"uint32\">", "kind": "type", "value": "uint32", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 4294967295", + "validate": "$importInternal(\"isTypeUint32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -286,7 +286,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -357,7 +357,7 @@ "name": "Type<\"uint32\">", "kind": "type", "value": "uint32", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 4294967295", + "validate": "$importInternal(\"isTypeUint32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -428,7 +428,7 @@ "name": "Type<\"int64\">", "kind": "type", "value": "int64", - "validate": "Math.floor($input) === $input && -9223372036854775808 <= $input && $input <= 9223372036854775807", + "validate": "$importInternal(\"isTypeInt64\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -499,7 +499,7 @@ "name": "Type<\"uint64\">", "kind": "type", "value": "uint64", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 18446744073709551615", + "validate": "$importInternal(\"isTypeUint64\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -570,7 +570,7 @@ "name": "Type<\"float\">", "kind": "type", "value": "float", - "validate": "-1.175494351e38 <= $input && $input <= 3.4028235e38", + "validate": "$importInternal(\"isTypeFloat\")($input)", "exclusive": true, "schema": { "type": "number" diff --git a/test/schemas/reflect/metadata/TypeTagTypeUnion.json b/test/schemas/reflect/metadata/TypeTagTypeUnion.json index 30e31ba304..bf9f40d5ff 100644 --- a/test/schemas/reflect/metadata/TypeTagTypeUnion.json +++ b/test/schemas/reflect/metadata/TypeTagTypeUnion.json @@ -76,7 +76,7 @@ "name": "Type<\"uint32\">", "kind": "type", "value": "uint32", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 4294967295", + "validate": "$importInternal(\"isTypeUint32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -89,7 +89,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -160,7 +160,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -173,7 +173,7 @@ "name": "Type<\"int64\">", "kind": "type", "value": "int64", - "validate": "Math.floor($input) === $input && -9223372036854775808 <= $input && $input <= 9223372036854775807", + "validate": "$importInternal(\"isTypeInt64\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -244,7 +244,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -257,7 +257,7 @@ "name": "Type<\"uint64\">", "kind": "type", "value": "uint64", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 18446744073709551615", + "validate": "$importInternal(\"isTypeUint64\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -328,7 +328,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -341,7 +341,7 @@ "name": "Type<\"float\">", "kind": "type", "value": "float", - "validate": "-1.175494351e38 <= $input && $input <= 3.4028235e38", + "validate": "$importInternal(\"isTypeFloat\")($input)", "exclusive": true, "schema": { "type": "number" @@ -412,7 +412,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -496,7 +496,7 @@ "name": "Type<\"int64\">", "kind": "type", "value": "int64", - "validate": "Math.floor($input) === $input && -9223372036854775808 <= $input && $input <= 9223372036854775807", + "validate": "$importInternal(\"isTypeInt64\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -509,7 +509,7 @@ "name": "Type<\"uint64\">", "kind": "type", "value": "uint64", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 18446744073709551615", + "validate": "$importInternal(\"isTypeUint64\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -580,7 +580,7 @@ "name": "Type<\"float\">", "kind": "type", "value": "float", - "validate": "-1.175494351e38 <= $input && $input <= 3.4028235e38", + "validate": "$importInternal(\"isTypeFloat\")($input)", "exclusive": true, "schema": { "type": "number" @@ -593,7 +593,7 @@ "name": "Type<\"int64\">", "kind": "type", "value": "int64", - "validate": "Math.floor($input) === $input && -9223372036854775808 <= $input && $input <= 9223372036854775807", + "validate": "$importInternal(\"isTypeInt64\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -677,7 +677,7 @@ "name": "Type<\"int64\">", "kind": "type", "value": "int64", - "validate": "Math.floor($input) === $input && -9223372036854775808 <= $input && $input <= 9223372036854775807", + "validate": "$importInternal(\"isTypeInt64\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -748,7 +748,7 @@ "name": "Type<\"float\">", "kind": "type", "value": "float", - "validate": "-1.175494351e38 <= $input && $input <= 3.4028235e38", + "validate": "$importInternal(\"isTypeFloat\")($input)", "exclusive": true, "schema": { "type": "number" @@ -832,7 +832,7 @@ "name": "Type<\"uint32\">", "kind": "type", "value": "uint32", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 4294967295", + "validate": "$importInternal(\"isTypeUint32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -845,7 +845,7 @@ "name": "Type<\"int32\">", "kind": "type", "value": "int32", - "validate": "Math.floor($input) === $input && -2147483648 <= $input && $input <= 2147483647", + "validate": "$importInternal(\"isTypeInt32\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -858,7 +858,7 @@ "name": "Type<\"float\">", "kind": "type", "value": "float", - "validate": "-1.175494351e38 <= $input && $input <= 3.4028235e38", + "validate": "$importInternal(\"isTypeFloat\")($input)", "exclusive": true, "schema": { "type": "number" @@ -884,7 +884,7 @@ "name": "Type<\"int64\">", "kind": "type", "value": "int64", - "validate": "Math.floor($input) === $input && -9223372036854775808 <= $input && $input <= 9223372036854775807", + "validate": "$importInternal(\"isTypeInt64\")($input)", "exclusive": true, "schema": { "type": "integer" @@ -897,7 +897,7 @@ "name": "Type<\"uint64\">", "kind": "type", "value": "uint64", - "validate": "Math.floor($input) === $input && 0 <= $input && $input <= 18446744073709551615", + "validate": "$importInternal(\"isTypeUint64\")($input)", "exclusive": true, "schema": { "type": "integer" diff --git a/test/src/debug/is.ts b/test/src/debug/is.ts index d25ab6f104..4ec1656665 100644 --- a/test/src/debug/is.ts +++ b/test/src/debug/is.ts @@ -1,12 +1,11 @@ import typia from "typia"; -import { CommentTagFormat } from "../structures/CommentTagFormat"; +import { TypeTagFormat } from "../structures/TypeTagFormat"; -const is = typia.createIs(); -console.log(is(CommentTagFormat.generate())); - -for (const spoiler of CommentTagFormat.SPOILERS) { - const value: CommentTagFormat = CommentTagFormat.generate(); - spoiler(value); - console.log(is(value)); -} +console.log(typia.validate(TypeTagFormat.generate())); +for (let i: number = 0; i < 1_000; ++i) + for (const spoiler of TypeTagFormat.SPOILERS) { + const data = TypeTagFormat.generate(); + spoiler(data); + if (typia.is(data) === true) console.log(spoiler.toString()); + } diff --git a/tsconfig.json b/tsconfig.json index f3914ece9a..1d4b4395e1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ /* Language and Environment */ - "target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + "target": "ES2015", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ "lib": [ "DOM", "ES2020"