Skip to content

Commit

Permalink
Fix validation bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MikuroXina committed Sep 4, 2023
1 parent a59b685 commit 3f09b14
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/lib/member-fetch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import YAML from "yaml";

export type SNSLinkInfo = { type: "twitter"; name: string } | { type: "github"; name: string };

function validateSNSLink(obj: unknown): obj is SNSLinkInfo {
Expand All @@ -12,8 +10,8 @@ function validateSNSLink(obj: unknown): obj is SNSLinkInfo {
console.error("unknown type from: ", obj);
return false;
}
if (!("url" in obj && typeof (obj as SNSLinkInfo).name === "string")) {
console.error("`url` not in: ", obj);
if (!("name" in obj && typeof (obj as SNSLinkInfo).name === "string")) {
console.error("`name` not in: ", obj);
return false;
}
return true;
Expand Down Expand Up @@ -43,7 +41,7 @@ function validateMember(obj: unknown): obj is Member {
return false;
}
if (!validateSNSLinks((obj as Member).associatedLinks)) {
console.error("`links` not in: ", obj);
console.error("`associatedLinks` not in: ", obj);
return false;
}

Expand Down

0 comments on commit 3f09b14

Please sign in to comment.