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)