From a3c980d7fd0af3cd8daedb05c921a16fbf4e44a2 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Mon, 24 Oct 2022 03:43:57 +0300 Subject: [PATCH] Update validate.js --- scripts/db/validate.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/db/validate.js b/scripts/db/validate.js index f6b0bf10..c1cd5cfc 100644 --- a/scripts/db/validate.js +++ b/scripts/db/validate.js @@ -91,7 +91,7 @@ async function main() { } } else if (filename === 'countries') { for (const [i, row] of rowsCopy.entries()) { - fileErrors = fileErrors.concat(validateCountryLanguage(row, i)) + fileErrors = fileErrors.concat(validateCountryLanguages(row, i)) } } else if (filename === 'subdivisions') { for (const [i, row] of rowsCopy.entries()) { @@ -295,13 +295,15 @@ function validateChannel(row, i) { return errors } -function validateCountryLanguage(row, i) { +function validateCountryLanguages(row, i) { const errors = [] - if (!db.languages[row.lang]) { - errors.push({ - line: i + 2, - message: `"${row.code}" has the wrong language "${row.lang}"` - }) + for (let lang of row.languages) { + if (!db.languages[lang]) { + errors.push({ + line: i + 2, + message: `"${row.code}" has the wrong language "${lang}"` + }) + } } return errors