Update validate.js

This commit is contained in:
Aleksandr Statciuk 2022-04-09 16:09:14 +03:00
parent 9a2cfb45f0
commit a8621f852d

View file

@ -75,6 +75,10 @@ async function main() {
for (const [i, row] of rows.entries()) { for (const [i, row] of rows.entries()) {
fileErrors = fileErrors.concat(await validateChannelId(row, i)) 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]) const schema = Joi.object(schemes[filename])
@ -206,6 +210,18 @@ async function validateChannelId(row, i) {
return errors 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) { function handleError(message) {
logger.error(chalk.red(`\n${message}`)) logger.error(chalk.red(`\n${message}`))
process.exit(1) process.exit(1)