Update validate.js

This commit is contained in:
Aleksandr Statciuk 2022-04-09 16:18:40 +03:00
parent ac360ca8cf
commit 67d7b98f2f

View file

@ -79,6 +79,10 @@ async function main() {
for (const [i, row] of rows.entries()) {
fileErrors = fileErrors.concat(validateCountryLanguage(row, i))
}
} else if (filename === 'subdivisions') {
for (const [i, row] of rows.entries()) {
fileErrors = fileErrors.concat(validateSubdivisionCountry(row, i))
}
}
const schema = Joi.object(schemes[filename])
@ -222,6 +226,18 @@ function validateCountryLanguage(row, i) {
return errors
}
function validateSubdivisionCountry(row, i) {
const errors = []
if (!db.countries[row.country]) {
errors.push({
line: i + 2,
message: `"${row.code}" has the wrong country "${row.country}"`
})
}
return errors
}
function handleError(message) {
logger.error(chalk.red(`\n${message}`))
process.exit(1)