Update validate.js

This commit is contained in:
Aleksandr Statciuk 2022-04-21 21:47:14 +03:00
parent f62c952edc
commit 9ef464fda0

View file

@ -78,6 +78,7 @@ async function main() {
fileErrors = fileErrors.concat(validateChannelBroadcastArea(row, i)) fileErrors = fileErrors.concat(validateChannelBroadcastArea(row, i))
fileErrors = fileErrors.concat(validateChannelSubdivision(row, i)) fileErrors = fileErrors.concat(validateChannelSubdivision(row, i))
fileErrors = fileErrors.concat(validateChannelCategories(row, i)) fileErrors = fileErrors.concat(validateChannelCategories(row, i))
fileErrors = fileErrors.concat(validateChannelReplacedBy(row, i))
fileErrors = fileErrors.concat(validateChannelLanguages(row, i)) fileErrors = fileErrors.concat(validateChannelLanguages(row, i))
fileErrors = fileErrors.concat(validateChannelCountry(row, i)) fileErrors = fileErrors.concat(validateChannelCountry(row, i))
} }
@ -172,6 +173,18 @@ function validateChannelCountry(row, i) {
return errors return errors
} }
function validateChannelReplacedBy(row, i) {
const errors = []
if (row.replaced_by && !db.channels[row.replaced_by]) {
errors.push({
line: i + 2,
message: `"${row.id}" has the wrong replaced_by "${row.replaced_by}"`
})
}
return errors
}
function validateChannelSubdivision(row, i) { function validateChannelSubdivision(row, i) {
const errors = [] const errors = []
if (row.subdivision && !db.subdivisions[row.subdivision]) { if (row.subdivision && !db.subdivisions[row.subdivision]) {