mirror of
https://github.com/iptv-org/database.git
synced 2024-11-26 12:31:27 -05:00
commit
2fd38a3a1b
4 changed files with 21 additions and 17 deletions
|
@ -55,12 +55,12 @@
|
||||||
|
|
||||||
### countries
|
### countries
|
||||||
|
|
||||||
| Field | Description | Required | Example |
|
| Field | Description | Required | Example |
|
||||||
| ----- | ------------------------------------------------------------------------------------------ | -------- | ------------ |
|
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | --------- |
|
||||||
| name | Official name of the country | Required | `Martinique` |
|
| name | Official name of the country | Required | `Canada` |
|
||||||
| code | [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code of the country | Required | `MQ` |
|
| code | [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code of the country | Required | `CA` |
|
||||||
| lang | Official language in the country | Required | `fra` |
|
| languages | List of official languages of the country separated by `;`. A list of all supported languages can be found in [data/languages.csv](data/languages.csv). | Required | `eng;fra` |
|
||||||
| flag | Country flag emoji | Required | `🇲🇶` |
|
| flag | Country flag emoji | Required | `🇨🇦` |
|
||||||
|
|
||||||
### subdivisions
|
### subdivisions
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
name,code,lang,flag
|
name,code,languages,flag
|
||||||
Afghanistan,AF,pus,🇦🇫
|
Afghanistan,AF,pus,🇦🇫
|
||||||
Albania,AL,sqi,🇦🇱
|
Albania,AL,sqi,🇦🇱
|
||||||
Algeria,DZ,ara,🇩🇿
|
Algeria,DZ,ara,🇩🇿
|
||||||
|
|
|
|
@ -7,9 +7,11 @@ module.exports = {
|
||||||
code: Joi.string()
|
code: Joi.string()
|
||||||
.regex(/^[A-Z]{2}$/)
|
.regex(/^[A-Z]{2}$/)
|
||||||
.required(),
|
.required(),
|
||||||
lang: Joi.string()
|
languages: Joi.array().items(
|
||||||
.regex(/^[a-z]{3}$/)
|
Joi.string()
|
||||||
.required(),
|
.regex(/^[a-z]{3}$/)
|
||||||
|
.required()
|
||||||
|
),
|
||||||
flag: Joi.string()
|
flag: Joi.string()
|
||||||
.regex(/^[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]$/)
|
.regex(/^[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]$/)
|
||||||
.required()
|
.required()
|
||||||
|
|
|
@ -91,7 +91,7 @@ async function main() {
|
||||||
}
|
}
|
||||||
} else if (filename === 'countries') {
|
} else if (filename === 'countries') {
|
||||||
for (const [i, row] of rowsCopy.entries()) {
|
for (const [i, row] of rowsCopy.entries()) {
|
||||||
fileErrors = fileErrors.concat(validateCountryLanguage(row, i))
|
fileErrors = fileErrors.concat(validateCountryLanguages(row, i))
|
||||||
}
|
}
|
||||||
} else if (filename === 'subdivisions') {
|
} else if (filename === 'subdivisions') {
|
||||||
for (const [i, row] of rowsCopy.entries()) {
|
for (const [i, row] of rowsCopy.entries()) {
|
||||||
|
@ -295,13 +295,15 @@ function validateChannel(row, i) {
|
||||||
return errors
|
return errors
|
||||||
}
|
}
|
||||||
|
|
||||||
function validateCountryLanguage(row, i) {
|
function validateCountryLanguages(row, i) {
|
||||||
const errors = []
|
const errors = []
|
||||||
if (!db.languages[row.lang]) {
|
for (let lang of row.languages) {
|
||||||
errors.push({
|
if (!db.languages[lang]) {
|
||||||
line: i + 2,
|
errors.push({
|
||||||
message: `"${row.code}" has the wrong language "${row.lang}"`
|
line: i + 2,
|
||||||
})
|
message: `"${row.code}" has the wrong language "${lang}"`
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors
|
return errors
|
||||||
|
|
Loading…
Reference in a new issue