LogoLogo

Schema Benchmarks

    • home
      Home

    • download_2
      Download

    • timer
      Initialization
    • check_circle
      Validation
    • output_circle
      Parsing
    • swap_horiz
      Codec
    • schema
      Standard Schema
    • format_quote
      String

    • error
      Stack
    • assignment_turned_in
      TypeScript

  • JSON Schema

    • data_object
      Schema to JSON
    • code
      JSON to Schema
    • verified
      Compliance

    • deployed_code
      Libraries

    • article
      Blog
Expand sidebarExpand sidebar
typia/Compiled (unminified)Compiled (unminified)
github
GitHubGitHub
DiscordDiscord
PreferencesPreferences
schemas/libraries/typia/download_compiled/index/unminified.js
code
View FormattedView Formatted
Copy to clipboardCopy to clipboard
Created by eskimojo for Open Circle

Preferences

Style
Theme
NPM browser
Code ligatures
schemas/libraries/typia/download_compiled/index/unminified.js
code
View FormattedView Formatted
Copy to clipboardCopy to clipboard
//#region ../node_modules/.pnpm/typia@15.1.0_ttsc@0.33.1/node_modules/typia/lib/internal/_isFormatUrl.mjs /** * Checks the `url` format, which is stricter than a generic URI. * * Accepts only the `http`, `https` and `ftp` schemes, an optional user and * password, a host that is a public IPv4 address or a dotted domain name with a * top-level label, an optional port of two to five digits and an optional path. * Hosts without a dot, such as `localhost`, private, loopback and link-local * IPv4 addresses, addresses whose last octet is 0 or 255, and IPv6 literals are * rejected. * * @evidence contracts/common.md#principled-implementation The expression is a public-web URL grammar, not the generic URI one: the schemes are limited to http, https and ftp, the host is a public IPv4 address (private, loopback, link-local and last-octet 0 or 255 addresses are excluded) or a dotted domain with a top-level label starting with a letter or a permitted Unicode character and allowing subsequent digits and hyphens, the port has two to five digits and the path has no spaces. The `url` format is a public-web extension alongside the generic `uri` format; its documented grammar rejects hosts without a dot, such as `localhost`, and IPv6 literals. * @evidence contracts/common.md#clear-and-simple-design One predicate and one private pattern, identical to the copy in @typia/utils. * @evidence contracts/common.md#prohibited-implementation-shortcuts The limits are stated and no host is special-cased. * @evidence contracts/common.md#meaningful-documentation The doc lists the accepted schemes and hosts and the rejected local addresses. */ const _isFormatUrl = (str) => 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]))|(?=.{1,253}(?::\d{2,5})?(?:\/[^\s]*)?$)(?:[a-z0-9\u00a1-\uffff](?:[-a-z0-9\u00a1-\uffff]{0,61}[a-z0-9\u00a1-\uffff])?\.)+(?:[a-z\u00a1-\uffff](?:[-a-z0-9\u00a1-\uffff]{0,61}[a-z0-9\u00a1-\uffff])))(?::\d{2,5})?(?:\/[^\s]*)?$/iu; //#endregion //#region ../node_modules/.pnpm/typia@15.1.0_ttsc@0.33.1/node_modules/typia/lib/internal/_stringLengthGte.mjs /** * Test whether a string has at least the given number of code points. * * Iteration stops as soon as the count is reached, so a long string is not * scanned to its end. * * @evidence contracts/common.md#principled-implementation The iterator is consumed only until the count reaches the requested minimum, which decides the lower bound without scanning the whole string; a minimum of zero is true at once. * @evidence contracts/common.md#clear-and-simple-design One loop with an early return. * @evidence contracts/common.md#prohibited-implementation-shortcuts The unit is code points. * @evidence contracts/common.md#meaningful-documentation The doc states the early return and the code point unit. */ const _stringLengthGte = (value, length) => { let count = 0; if (length <= count) return true; for (const _ch of value) if (length <= ++count) return true; return false; }; //#endregion //#region ../node_modules/.pnpm/typia@15.1.0_ttsc@0.33.1/node_modules/typia/lib/internal/_stringLengthLte.mjs /** * Test whether a string has at most the given number of code points. * * Iteration stops as soon as the count is exceeded, so a long string is not * scanned to its end. * * @evidence contracts/common.md#principled-implementation The iterator is consumed until the count exceeds the maximum, which decides the upper bound without scanning past it; a negative maximum is false at once. * @evidence contracts/common.md#clear-and-simple-design One loop with an early return. * @evidence contracts/common.md#prohibited-implementation-shortcuts The unit is code points. * @evidence contracts/common.md#meaningful-documentation The doc states the early return and the code point unit. */ const _stringLengthLte = (value, length) => { let count = 0; if (!(count <= length)) return false; for (const _ch of value) if (!(++count <= length)) return false; return true; }; //#endregion //#region ../node_modules/.pnpm/typia@15.1.0_ttsc@0.33.1/node_modules/typia/lib/internal/_validateReport.mjs /** * Create the reporter that validation functions use to collect errors. * * The returned function keeps an error only when it is exceptionable and its * path is neither an ancestor nor a descendant of the last kept path, so a * failing leaf is not also reported as every enclosing value. An undefined * value gets a default description when none was supplied. Kept errors retain * their original references, and filling that description updates the error. It * always returns false so emitted code can return it directly. * * @evidence contracts/common.md#principled-implementation The reporter pushes the original error onto the list only when it is exceptionable and its path is neither an ancestor nor a descendant of the last pushed one, so a failing leaf is not also reported as every enclosing value. For an undefined value it fills a missing description while preserving supplied text; it always returns false so emitted code can return it directly. * @evidence contracts/common.md#clear-and-simple-design One closure with two private predicates. * @evidence contracts/common.md#prohibited-implementation-shortcuts The suppression is path-based and general. * @evidence contracts/common.md#meaningful-documentation A comment states the suppression and the false result. */ const _validateReport = (array) => { const isAncestor = (ancestor, descendant) => descendant === ancestor || descendant.startsWith(`${ancestor}.`) || descendant.startsWith(`${ancestor}[`); const reportable = (path) => { if (array.length === 0) return true; const last = array[array.length - 1].path; return isAncestor(path, last) === false && isAncestor(last, path) === false; }; return (exceptable, error) => { if (exceptable && reportable(error.path)) { if (error.value === void 0) error.description ??= [ "The value at this path is `undefined`.", "", `Please fill the \`${error.expected}\` typed value next time.` ].join("\n"); array.push(error); } return false; }; }; //#endregion //#region ../schemas/libraries/typia/download/index.ts (() => { const _ip0 = (input) => "number" === typeof input["id"]; const _ip1 = (input) => input["created"] instanceof Date; const _ip2 = (input) => "string" === typeof input["title"] && _stringLengthGte(input["title"], 1) && _stringLengthLte(input["title"], 100); const _ip3 = (input) => Array.isArray(input["images"]) && input["images"].every((elem) => "object" === typeof elem && null !== elem && _io1(elem)); const _ve0 = "{ id: number; created: Date; title: string & MinLength<1> & MaxLength<100>; brand: string & MinLength<1> & MaxLength<30>; description: string & ... 1 more ... & MaxLength<...>; ... 5 more ...; ratings: RatingSchema[]; }"; const _vp0 = (input, _path, _exceptionable = true) => "number" === typeof input["id"] || _report(_exceptionable, { path: _path + ".id", expected: "number", value: input["id"] }); const _vp1 = (input, _path, _exceptionable = true) => input["created"] instanceof Date || _report(_exceptionable, { path: _path + ".created", expected: "Date", value: input["created"] }); const _vp2 = (input, _path, _exceptionable = true) => "string" === typeof input["title"] && (_stringLengthGte(input["title"], 1) || _report(_exceptionable, { path: _path + ".title", expected: "string & MinLength<1>", value: input["title"] })) && (_stringLengthLte(input["title"], 100) || _report(_exceptionable, { path: _path + ".title", expected: "string & MaxLength<100>", value: input["title"] })) || _report(_exceptionable, { path: _path + ".title", expected: "(string & MinLength<1> & MaxLength<100>)", value: input["title"] }); const _vp3 = (input, _path, _exceptionable = true) => (Array.isArray(input["images"]) || _report(_exceptionable, { path: _path + ".images", expected: "Array<ImageSchema>", value: input["images"] })) && input["images"].map((elem, _index5) => ("object" === typeof elem && null !== elem || _report(_exceptionable, { path: _path + ".images[" + _index5 + "]", expected: "ImageSchema", value: elem })) && _vo1(elem, _path + ".images[" + _index5 + "]", _exceptionable) || _report(_exceptionable, { path: _path + ".images[" + _index5 + "]", expected: "ImageSchema", value: elem })).every((flag) => flag) || _report(_exceptionable, { path: _path + ".images", expected: "Array<ImageSchema>", value: input["images"] }); const _io0 = (input) => _ip0(input) && _ip1(input) && _ip2(input) && "string" === typeof input.brand && _stringLengthGte(input.brand, 1) && _stringLengthLte(input.brand, 30) && "string" === typeof input.description && _stringLengthGte(input.description, 1) && _stringLengthLte(input.description, 500) && "number" === typeof input.price && 1 <= input.price && input.price <= 1e4 && (null === input.discount || "number" === typeof input.discount && 1 <= input.discount && input.discount <= 100) && "number" === typeof input.quantity && 0 <= input.quantity && input.quantity <= 10 && Array.isArray(input.tags) && input.tags.every((elem) => "string" === typeof elem && _stringLengthGte(elem, 1) && _stringLengthLte(elem, 30)) && _ip3(input) && Array.isArray(input.ratings) && input.ratings.every((elem) => "object" === typeof elem && null !== elem && _io2(elem)); const _io1 = (input) => _ip0(input) && _ip1(input) && _ip2(input) && ("jpg" === input.type || "png" === input.type) && "number" === typeof input.size && "string" === typeof input.url && _isFormatUrl(input.url); const _io2 = (input) => _ip0(input) && "number" === typeof input.stars && 1 <= input.stars && input.stars <= 5 && _ip2(input) && "string" === typeof input.text && _stringLengthGte(input.text, 1) && _stringLengthLte(input.text, 1e3) && _ip3(input); const _vo0 = (input, _path, _exceptionable = true) => [ _vp0(input, _path, _exceptionable), _vp1(input, _path, _exceptionable), _vp2(input, _path, _exceptionable), "string" === typeof input.brand && (_stringLengthGte(input.brand, 1) || _report(_exceptionable, { path: _path + ".brand", expected: "string & MinLength<1>", value: input.brand })) && (_stringLengthLte(input.brand, 30) || _report(_exceptionable, { path: _path + ".brand", expected: "string & MaxLength<30>", value: input.brand })) || _report(_exceptionable, { path: _path + ".brand", expected: "(string & MinLength<1> & MaxLength<30>)", value: input.brand }), "string" === typeof input.description && (_stringLengthGte(input.description, 1) || _report(_exceptionable, { path: _path + ".description", expected: "string & MinLength<1>", value: input.description })) && (_stringLengthLte(input.description, 500) || _report(_exceptionable, { path: _path + ".description", expected: "string & MaxLength<500>", value: input.description })) || _report(_exceptionable, { path: _path + ".description", expected: "(string & MinLength<1> & MaxLength<500>)", value: input.description }), "number" === typeof input.price && (1 <= input.price || _report(_exceptionable, { path: _path + ".price", expected: "number & Minimum<1>", value: input.price })) && (input.price <= 1e4 || _report(_exceptionable, { path: _path + ".price", expected: "number & Maximum<10000>", value: input.price })) || _report(_exceptionable, { path: _path + ".price", expected: "(number & Minimum<1> & Maximum<10000>)", value: input.price }), null === input.discount || "number" === typeof input.discount && (1 <= input.discount || _report(_exceptionable, { path: _path + ".discount", expected: "number & Minimum<1>", value: input.discount })) && (input.discount <= 100 || _report(_exceptionable, { path: _path + ".discount", expected: "number & Maximum<100>", value: input.discount })) || _report(_exceptionable, { path: _path + ".discount", expected: "((number & Minimum<1> & Maximum<100>) | null)", value: input.discount }), "number" === typeof input.quantity && (0 <= input.quantity || _report(_exceptionable, { path: _path + ".quantity", expected: "number & Minimum<0>", value: input.quantity })) && (input.quantity <= 10 || _report(_exceptionable, { path: _path + ".quantity", expected: "number & Maximum<10>", value: input.quantity })) || _report(_exceptionable, { path: _path + ".quantity", expected: "(number & Minimum<0> & Maximum<10>)", value: input.quantity }), (Array.isArray(input.tags) || _report(_exceptionable, { path: _path + ".tags", expected: "Array<string & MinLength<1> & MaxLength<30>>", value: input.tags })) && input.tags.map((elem, _index4) => "string" === typeof elem && (_stringLengthGte(elem, 1) || _report(_exceptionable, { path: _path + ".tags[" + _index4 + "]", expected: "string & MinLength<1>", value: elem })) && (_stringLengthLte(elem, 30) || _report(_exceptionable, { path: _path + ".tags[" + _index4 + "]", expected: "string & MaxLength<30>", value: elem })) || _report(_exceptionable, { path: _path + ".tags[" + _index4 + "]", expected: "(string & MinLength<1> & MaxLength<30>)", value: elem })).every((flag) => flag) || _report(_exceptionable, { path: _path + ".tags", expected: "Array<string & MinLength<1> & MaxLength<30>>", value: input.tags }), _vp3(input, _path, _exceptionable), (Array.isArray(input.ratings) || _report(_exceptionable, { path: _path + ".ratings", expected: "Array<RatingSchema>", value: input.ratings })) && input.ratings.map((elem, _index6) => ("object" === typeof elem && null !== elem || _report(_exceptionable, { path: _path + ".ratings[" + _index6 + "]", expected: "RatingSchema", value: elem })) && _vo2(elem, _path + ".ratings[" + _index6 + "]", _exceptionable) || _report(_exceptionable, { path: _path + ".ratings[" + _index6 + "]", expected: "RatingSchema", value: elem })).every((flag) => flag) || _report(_exceptionable, { path: _path + ".ratings", expected: "Array<RatingSchema>", value: input.ratings }) ].every((flag) => flag); const _vo1 = (input, _path, _exceptionable = true) => [ _vp0(input, _path, _exceptionable), _vp1(input, _path, _exceptionable), _vp2(input, _path, _exceptionable), "jpg" === input.type || "png" === input.type || _report(_exceptionable, { path: _path + ".type", expected: "(\"jpg\" | \"png\")", value: input.type }), "number" === typeof input.size || _report(_exceptionable, { path: _path + ".size", expected: "number", value: input.size }), "string" === typeof input.url && (_isFormatUrl(input.url) || _report(_exceptionable, { path: _path + ".url", expected: "string & Format<\"url\">", value: input.url })) || _report(_exceptionable, { path: _path + ".url", expected: "(string & Format<\"url\">)", value: input.url }) ].every((flag) => flag); const _vo2 = (input, _path, _exceptionable = true) => [ _vp0(input, _path, _exceptionable), "number" === typeof input.stars && (1 <= input.stars || _report(_exceptionable, { path: _path + ".stars", expected: "number & Minimum<1>", value: input.stars })) && (input.stars <= 5 || _report(_exceptionable, { path: _path + ".stars", expected: "number & Maximum<5>", value: input.stars })) || _report(_exceptionable, { path: _path + ".stars", expected: "(number & Minimum<1> & Maximum<5>)", value: input.stars }), _vp2(input, _path, _exceptionable), "string" === typeof input.text && (_stringLengthGte(input.text, 1) || _report(_exceptionable, { path: _path + ".text", expected: "string & MinLength<1>", value: input.text })) && (_stringLengthLte(input.text, 1e3) || _report(_exceptionable, { path: _path + ".text", expected: "string & MaxLength<1000>", value: input.text })) || _report(_exceptionable, { path: _path + ".text", expected: "(string & MinLength<1> & MaxLength<1000>)", value: input.text }), _vp3(input, _path, _exceptionable) ].every((flag) => flag); const __is = (input) => "object" === typeof input && null !== input && _io0(input); let errors; let _report; return (input) => { if (false === __is(input)) { errors = []; _report = _validateReport(errors); ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, { path: _path + "", expected: _ve0, value: input })) && _vo0(input, _path + "", true) || _report(true, { path: _path + "", expected: _ve0, value: input }))(input, "$input", true); const success = 0 === errors.length; return success ? { success, data: input } : { success, errors, data: input }; } return { success: true, data: input }; }; })()({}); //#endregion