mirror of
https://github.com/iptv-org/database.git
synced 2024-11-21 18:42:31 -05:00
Update validate.js
This commit is contained in:
parent
67d7b98f2f
commit
95cd92015b
1 changed files with 18 additions and 0 deletions
|
@ -83,6 +83,10 @@ async function main() {
|
|||
for (const [i, row] of rows.entries()) {
|
||||
fileErrors = fileErrors.concat(validateSubdivisionCountry(row, i))
|
||||
}
|
||||
} else if (filename === 'regions') {
|
||||
for (const [i, row] of rows.entries()) {
|
||||
fileErrors = fileErrors.concat(validateRegionCountries(row, i))
|
||||
}
|
||||
}
|
||||
|
||||
const schema = Joi.object(schemes[filename])
|
||||
|
@ -238,6 +242,20 @@ function validateSubdivisionCountry(row, i) {
|
|||
return errors
|
||||
}
|
||||
|
||||
function validateRegionCountries(row, i) {
|
||||
const errors = []
|
||||
row.countries.forEach(country => {
|
||||
if (!db.countries[country]) {
|
||||
errors.push({
|
||||
line: i + 2,
|
||||
message: `"${row.code}" has the wrong country "${country}"`
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return errors
|
||||
}
|
||||
|
||||
function handleError(message) {
|
||||
logger.error(chalk.red(`\n${message}`))
|
||||
process.exit(1)
|
||||
|
|
Loading…
Reference in a new issue