Skip to content

Commit

Permalink
Fix #1498: problem of tags.Examples<Rec> (#1499)
Browse files Browse the repository at this point in the history
* Fix #1498: problem of tags.Examples

* Missed prettier
  • Loading branch information
samchon authored Feb 11, 2025
1 parent 59b9c95 commit e0a7ffa
Show file tree
Hide file tree
Showing 9 changed files with 717 additions and 680 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": "7.6.3",
"version": "7.6.4",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
16 changes: 9 additions & 7 deletions src/factories/MetadataTypeTagFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ export namespace MetadataTypeTagFactory {

// CHECK LIST OF PROPERTIES
const tag: MetadataObjectType = top.value.objects[0]!.type;
const statics: string[] = tag.properties
const statistics: string[] = tag.properties
.map((p) => p.key.getSoleLiteral()!)
.filter((str) => str !== null);
if (ESSENTIAL_FIELDS.some((f) => !statics.includes(f)))
if (ESSENTIAL_FIELDS.some((f) => !statistics.includes(f)))
return report({
property: null,
message: `must have at least three properties - ${ESSENTIAL_FIELDS.map(
Expand Down Expand Up @@ -223,14 +223,16 @@ export namespace MetadataTypeTagFactory {
else if (
// VALUE
props.key === "value" &&
(props.value.size() > 1 ||
(props.value.size() !== 0 &&
(props.value.constants.length !== 1 ||
props.value.constants[0]!.values.length !== 1)))
!(
(props.value.size() === 0 && props.value.isRequired() === false) ||
(props.value.size() === 1 &&
(props.value.objects.length === 1 ||
props.value.constants.length === 1))
)
)
return props.report({
property: props.key,
message: "must be a constant literal type or undefined value",
message: "must be a literal type or undefined value",
});
else if (props.key === "exclusive") return get_exclusive(props) !== null;
else if (props.key === "validate") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ export const iterate_metadata_intersection = (
objects: tagObjects,
explore: props.explore,
});

Object.assign(props.collection, commit);
iterate_metadata({
...props,
Expand Down
6 changes: 3 additions & 3 deletions src/tags/Examples.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { TagBase } from "./TagBase";

export type Examples<
Dict extends Record<
Value extends Record<
string,
boolean | bigint | number | string | object | Array<unknown> | null
>,
> = TagBase<{
target: "boolean" | "bigint" | "number" | "string" | "array" | "object";
kind: "examples";
value: Dict;
value: Value;
exclusive: true;
schema: {
examples: Dict;
examples: Value;
};
}>;
Loading

0 comments on commit e0a7ffa

Please sign in to comment.