Array of normalized manga items to validate.
Array of validated manga items ready for storage.
export function validateMangaData(manga: NormalizedMangaItem[]): KenmeiManga[] {
console.debug(`[MangaImport] Validating ${manga.length} manga items`);
const validated = manga.map((mangaItem, idx) => ({
id: mangaItem.id ?? `merged_${Date.now()}_${idx}`,
title: mangaItem.title,
status: mangaItem.status,
score: mangaItem.score ?? 0,
chaptersRead: mangaItem.chaptersRead ?? 0,
volumesRead: mangaItem.volumesRead ?? 0,
notes: mangaItem.notes ?? "",
createdAt: mangaItem.createdAt ?? new Date().toISOString(),
updatedAt: mangaItem.updatedAt ?? new Date().toISOString(),
lastReadAt: mangaItem.lastReadAt,
}));
console.debug(
`[MangaImport] Validation complete for ${validated.length} items`,
);
return validated;
}
Validates and standardizes manga data with proper IDs, timestamps, and default field values for storage.