| 77 | } |
| 78 | |
| 79 | function checkEnumFields( |
| 80 | fm: ParsedFrontmatter, |
| 81 | issues: ValidationIssue[] |
| 82 | ): void { |
| 83 | for (const [name, allowed] of Object.entries(ENUM_FIELDS)) { |
| 84 | const field = fm.fields.get(name); |
| 85 | if (!field) continue; |
| 86 | |
| 87 | const val = field.value; |
| 88 | // Empty is always allowed |
| 89 | if (val === null || val === undefined || val === "") continue; |
| 90 | |
| 91 | if (typeof val !== "string" || !allowed.includes(val)) { |
| 92 | const severity: Severity = name === "type" ? "warning" : "error"; |
| 93 | issues.push({ |
| 94 | severity, |
| 95 | message: `invalid ${name}: '${val}' (valid values: ${allowed.join(", ")})`, |
| 96 | field: name, |
| 97 | target: "value", |
| 98 | }); |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | function checkArrayFields( |
| 104 | fm: ParsedFrontmatter, |