This commit is contained in:
parent
8dda6b1014
commit
f4e31cea36
@ -367,7 +367,16 @@ export async function addChoice(login: string, trusted: boolean, locationKey: Lo
|
|||||||
* @param date datum, pro které je validace prováděna
|
* @param date datum, pro které je validace prováděna
|
||||||
*/
|
*/
|
||||||
async function validateFoodIndex(locationKey: LocationKey, foodIndex?: number, date?: Date) {
|
async function validateFoodIndex(locationKey: LocationKey, foodIndex?: number, date?: Date) {
|
||||||
if (locationKey in Restaurants && foodIndex != null) {
|
if (foodIndex != null) {
|
||||||
|
if (typeof foodIndex !== 'number') {
|
||||||
|
throw Error(`Neplatný index ${foodIndex} typu ${typeof foodIndex}`);
|
||||||
|
}
|
||||||
|
if (foodIndex < 0) {
|
||||||
|
throw Error(`Neplatný index ${foodIndex}`);
|
||||||
|
}
|
||||||
|
if (!(locationKey in Restaurants)) {
|
||||||
|
throw Error(`Neplatný index ${foodIndex} pro lokalitu ${locationKey} nepodporující indexy`);
|
||||||
|
}
|
||||||
const usedDate = date ?? getToday();
|
const usedDate = date ?? getToday();
|
||||||
const restaurantKey = Restaurants[locationKey as keyof typeof Restaurants]
|
const restaurantKey = Restaurants[locationKey as keyof typeof Restaurants]
|
||||||
const menu = await getRestaurantMenu(restaurantKey, usedDate);
|
const menu = await getRestaurantMenu(restaurantKey, usedDate);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user