add: harden thumbnail generation and validate image assets
All checks were successful
Deploy on push / deploy (push) Has been skipped
All checks were successful
Deploy on push / deploy (push) Has been skipped
This commit is contained in:
@@ -47,6 +47,8 @@ function validateMeals(meals) {
|
||||
throw new Error("data/meals.json must contain an array");
|
||||
}
|
||||
|
||||
const ids = new Set();
|
||||
|
||||
for (const [index, meal] of meals.entries()) {
|
||||
if (!meal || typeof meal !== "object") {
|
||||
throw new Error(`Meal at index ${index} must be an object`);
|
||||
@@ -62,6 +64,12 @@ function validateMeals(meals) {
|
||||
throw new Error(`Meal ${index} has a non-string "position" value`);
|
||||
}
|
||||
|
||||
if (ids.has(meal.id)) {
|
||||
throw new Error(`Duplicate meal id "${meal.id}" found in data/meals.json`);
|
||||
}
|
||||
|
||||
ids.add(meal.id);
|
||||
|
||||
validateThumbnail(meal, index);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user