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