From a8621f852d48e402f23333b07b69aafdbe12ba56 Mon Sep 17 00:00:00 2001 From: Aleksandr Statciuk Date: Sat, 9 Apr 2022 16:09:14 +0300 Subject: [PATCH] Update validate.js --- scripts/db/validate.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripts/db/validate.js b/scripts/db/validate.js index 7f39d37d..096cd45e 100644 --- a/scripts/db/validate.js +++ b/scripts/db/validate.js @@ -75,6 +75,10 @@ async function main() { for (const [i, row] of rows.entries()) { fileErrors = fileErrors.concat(await validateChannelId(row, i)) } + } else if (filename === 'countries') { + for (const [i, row] of rows.entries()) { + fileErrors = fileErrors.concat(await validateCountryLanguage(row, i)) + } } const schema = Joi.object(schemes[filename]) @@ -206,6 +210,18 @@ async function validateChannelId(row, i) { return errors } +async function validateCountryLanguage(row, i) { + const errors = [] + if (!db.languages[row.lang]) { + errors.push({ + line: i + 2, + message: `"${row.code}" has the wrong language "${row.lang}"` + }) + } + + return errors +} + function handleError(message) { logger.error(chalk.red(`\n${message}`)) process.exit(1)