feat : update
This commit is contained in:
@@ -34,7 +34,7 @@ function indexAfter(path: readonly PropertyKey[], key: string): number | null {
|
||||
return position >= 0 && typeof value === "number" ? value : null;
|
||||
}
|
||||
|
||||
function issueContext(section: GuideValidationSection, path: readonly PropertyKey[]): string {
|
||||
function issueContext(section: GuideValidationSection, path: readonly PropertyKey[], teamNames?: readonly string[]): string {
|
||||
const rowIndex = indexAfter(path, "rows");
|
||||
const groupIndex = indexAfter(path, "groups");
|
||||
const teamIndex = indexAfter(path, "teams");
|
||||
@@ -50,7 +50,8 @@ function issueContext(section: GuideValidationSection, path: readonly PropertyKe
|
||||
return rowIndex === null ? `Condition ${groupIndex + 1}` : `Condition ${groupIndex + 1} · C${rowIndex + 1}`;
|
||||
}
|
||||
if (section === "team" && teamIndex !== null) {
|
||||
return memberIndex === null ? `Team ${teamIndex + 1}` : `Team ${teamIndex + 1} · ตัวละคร ${memberIndex + 1}`;
|
||||
const teamName = teamNames?.[teamIndex]?.trim() || `Team ${teamIndex + 1}`;
|
||||
return memberIndex === null ? teamName : `${teamName} · ตัวละคร ${memberIndex + 1}`;
|
||||
}
|
||||
if (section === "extra" && sectionIndex !== null) {
|
||||
return rowIndex === null ? `Extra section ${sectionIndex + 1}` : `Extra section ${sectionIndex + 1} · แถว ${rowIndex + 1}`;
|
||||
@@ -67,6 +68,10 @@ function issueMessage(issue: ValidationIssue): string {
|
||||
return "กรุณาตรวจสอบข้อมูลให้ถูกต้อง";
|
||||
}
|
||||
|
||||
export function formatGuideValidationIssues(section: GuideValidationSection, issues: readonly ValidationIssue[]): string[] {
|
||||
return issues.map((issue) => `${issueContext(section, issue.path)}: ${issueMessage(issue)}`);
|
||||
export function formatGuideValidationIssues(
|
||||
section: GuideValidationSection,
|
||||
issues: readonly ValidationIssue[],
|
||||
options: { teamNames?: readonly string[] } = {},
|
||||
): string[] {
|
||||
return issues.map((issue) => `${issueContext(section, issue.path, options.teamNames)}: ${issueMessage(issue)}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user