Skip to content

Commit

Permalink
Merge pull request #1337 from samchon/feat/template-json-schema
Browse files Browse the repository at this point in the history
Fix JSON schema bug when template string type with tags.
  • Loading branch information
samchon authored Oct 22, 2024
2 parents c25deee + 0079199 commit af07a16
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 35 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": "6.11.2",
"version": "6.11.3",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/programmers/internal/application_templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const application_templates = <Version extends "3.0" | "3.1">(
});
for (const tpl of taggedTemplates)
output.push(
application_plugin(
...(application_plugin(
{
type: "string",
pattern: metadata_to_pattern(false)(
Expand All @@ -44,7 +44,7 @@ export const application_templates = <Version extends "3.0" | "3.1">(
),
},
tpl.tags ?? [],
) as any,
) as Schema<Version>[]),
);
return output;
};
Expand Down
2 changes: 1 addition & 1 deletion src/programmers/internal/application_v30_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const application_v30_schema =

// ATOMIC TYPES
if (meta.templates.length && AtomicPredicator.template(meta))
application_templates(meta).map(insert);
application_templates(meta).forEach(insert);
for (const constant of meta.constants)
if (AtomicPredicator.constant(meta)(constant.type) === false) continue;
else insert(application_v30_constant(constant));
Expand Down
4 changes: 2 additions & 2 deletions src/programmers/internal/application_v31_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ export const application_v31_schema =

// ATOMIC TYPES
if (meta.templates.length && AtomicPredicator.template(meta))
application_templates(meta).map(insert as any);
application_templates(meta).forEach(insert as any);
for (const constant of meta.constants)
if (AtomicPredicator.constant(meta)(constant.type) === false) continue;
else application_v31_constant(constant).map(insert);
else application_v31_constant(constant).forEach(insert);
for (const a of meta.atomics)
if (a.type === "boolean") application_boolean(a).forEach(insert as any);
else if (a.type === "bigint")
Expand Down
2 changes: 1 addition & 1 deletion src/programmers/internal/llm_schema_station.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const llm_schema_station = (props: {
props.metadata.templates.length &&
AtomicPredicator.template(props.metadata)
)
application_templates<"3.0">(props.metadata).map(insert);
application_templates<"3.0">(props.metadata).forEach(insert);
for (const constant of props.metadata.constants)
if (AtomicPredicator.constant(props.metadata)(constant.type) === false)
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,24 @@ const validate = (app: IJsonApplication<"3.0"> | IJsonApplication<"3.1">) => {
"^(([+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?\\/[+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)|((.*)\\x2d(.*)))",
},
sole: {
"0": {
type: "string",
pattern:
"([+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?\\/[+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)",
"x-typia-sole": true,
},
type: "string",
pattern:
"([+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?\\/[+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)",
"x-typia-sole": true,
},
union: {
oneOf: [
[
{
type: "string",
pattern:
"([+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?\\/[+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)",
"x-typia-something": true,
},
],
[
{
type: "string",
pattern: "((.*)\\x2d(.*))",
"x-typia-nothing": false,
},
],
{
type: "string",
pattern:
"([+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?\\/[+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)",
"x-typia-something": true,
},
{
type: "string",
pattern: "((.*)\\x2d(.*))",
"x-typia-nothing": false,
},
],
},
mixed: {
Expand All @@ -49,13 +43,11 @@ const validate = (app: IJsonApplication<"3.0"> | IJsonApplication<"3.1">) => {
pattern:
"^(([+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?\\/[+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)|((.*)\\x2d(.*)))",
},
[
{
type: "string",
pattern: "((.*)\\|\\|[+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)",
"x-typia-something": true,
},
],
{
type: "string",
pattern: "((.*)\\|\\|[+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)",
"x-typia-something": true,
},
],
},
})(properties);
Expand Down

0 comments on commit af07a16

Please sign in to comment.