Source document

scripts/loaders/miami/event-school-identity.ts

Served verbatim from the project repository. Internal working document conventions apply: documents may reference file paths, branch names, and findings-ledger anchors from the repo.

/** Compare a hand-entered source identity with the official directory before loading. */
export function assertEventSchoolIdentity(schoolNumber: string, sourceName: string, directoryName?: string) {
  if (!sourceName.trim()) return;
  const normalize = (name: string) => name.normalize("NFKD").toUpperCase().replace(/[^A-Z0-9]/g, "");
  if (!directoryName || normalize(sourceName) !== normalize(directoryName)) {
    throw new Error(`[events] ${schoolNumber}: source school '${sourceName}' does not match directory '${directoryName ?? "MISSING"}'`);
  }
}