Skip to content

Commit

Permalink
Fix length error of typia.random<T>() function.
Browse files Browse the repository at this point in the history
When generating random string value from `typia.random<T>()` function with `tags.MaxLength<1>` tag, `typia.random<T>()` function had not returned the one length string value, but had returned the 5 length string. Such bug being repeated until configure the `tags.MaxLength<5>` over value.

This PR changes the invalid random length algorith, so that the bug has been fixed.
  • Loading branch information
samchon committed Nov 29, 2023
1 parent 71f2187 commit f077347
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 41 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typia",
"version": "5.3.1",
"version": "5.3.2",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@
"suppress-warnings": "^1.0.2",
"tstl": "^2.5.13",
"uuid": "^9.0.1",
"typia": "D:\\github\\samchon\\typia\\typia-5.3.1.tgz"
"typia": "D:\\github\\samchon\\typia\\typia-5.3.2.tgz"
}
}
2 changes: 1 addition & 1 deletion packages/errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"typescript": "^5.3.2"
},
"dependencies": {
"typia": "D:\\github\\samchon\\typia\\typia-5.3.1.tgz"
"typia": "D:\\github\\samchon\\typia\\typia-5.3.2.tgz"
}
}
2 changes: 1 addition & 1 deletion packages/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
"suppress-warnings": "^1.0.2",
"tstl": "^2.5.13",
"uuid": "^9.0.1",
"typia": "D:\\github\\samchon\\typia\\typia-5.3.1.tgz"
"typia": "D:\\github\\samchon\\typia\\typia-5.3.2.tgz"
}
}
4 changes: 2 additions & 2 deletions packages/typescript-json/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-json",
"version": "5.3.1",
"version": "5.3.2",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -56,7 +56,7 @@
},
"homepage": "https://typia.io",
"dependencies": {
"typia": "5.3.1"
"typia": "5.3.2"
},
"peerDependencies": {
"typescript": ">=4.8.0 <5.4.0"
Expand Down
7 changes: 7 additions & 0 deletions src/programmers/helpers/RandomRanger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export namespace RandomRanger {
if (props.minimum === undefined && props.maximum === undefined)
return undefined;

if (props.maximum !== undefined && props.minimum === undefined) {
if (props.maximum <= 0) {
props.maximum = 0;
props.minimum = 0;
} else if (props.maximum < defs.gap)
props.minimum = defs.minimum === 0 ? 0 : 1;
}
props.minimum ??= defs.minimum;
props.maximum ??= defs.maximum;
if (props.maximum < props.minimum) (props.maximum as number) += defs.gap;
Expand Down
12 changes: 2 additions & 10 deletions src/transformers/CallExpressionTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,8 @@ export namespace CallExpressionTransformer {

const isTarget = (location: string): boolean => {
const files: string[] = Object.keys(FUNCTORS);
return files.some(
(f) =>
location.includes(
path.join("node_modules", "typia", "lib", `${f}.d.ts`),
) ||
location === path.resolve(path.join(__dirname, "..", `${f}.ts`)) ||
location ===
path.resolve(
path.join(__dirname, "..", "..", "..", "src", `${f}.ts`),
),
return files.some((f) =>
location.includes(path.join("node_modules", "typia", "lib", `${f}.d.ts`)),
);
};
}
Expand Down
8 changes: 4 additions & 4 deletions website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
"prettier": "^2.8.8",
"rimraf": "^5.0.0",
"ts-node": "^10.9.1",
"typia": "^5.3.1"
"typia": "^5.3.2"
}
}
40 changes: 20 additions & 20 deletions website/public/sitemap-0.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url><loc>https://typia.io/</loc><lastmod>2023-11-27T08:14:01.523Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/json/parse/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/json/schema/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/json/stringify/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/misc/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/protobuf/decode/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/protobuf/encode/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/protobuf/message/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/pure/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/random/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/setup/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/utilization/nestjs/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/utilization/prisma/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/utilization/trpc/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/validators/assert/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/validators/is/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/validators/tags/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/validators/validate/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/playground/</loc><lastmod>2023-11-27T08:14:01.524Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/</loc><lastmod>2023-11-29T17:50:58.866Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/json/parse/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/json/schema/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/json/stringify/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/misc/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/protobuf/decode/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/protobuf/encode/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/protobuf/message/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/pure/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/random/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/setup/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/utilization/nestjs/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/utilization/prisma/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/utilization/trpc/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/validators/assert/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/validators/is/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/validators/tags/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/docs/validators/validate/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
<url><loc>https://typia.io/playground/</loc><lastmod>2023-11-29T17:50:58.867Z</lastmod><changefreq>daily</changefreq><priority>0.7</priority></url>
</urlset>

0 comments on commit f077347

Please sign in to comment.