Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
- run: npm ci
- run: npm run format:check
- run: npm run lint
- run: npm run validate:data

test:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions DATA_REQUIREMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Additional format notes:
## 5) Testing

- Add test cases to `test/tests.js` under `countriesPostalCodes`: include the country ISO/name, a representative zip, expected region code, and set `usingGoogle: false`.
- Run `npm run validate:data` to verify data-file consistency and static country/geocode allowlists.
- Run `npm test` to execute the Node.js test runner.
- Optional: verify pretty-name lookups via `getNameFromCountryAndRegion` using the `regionNames` file.

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ console.log(name); // Thüringen
npm test
npm run lint
npm run format:check
npm run validate:data
```

`npm run validate:data` checks consistency between `country/*.json`, `regions/*.json`, `regionNames/*.json`, and the statically supported countries in `lib/region.js`.
`npm run validate:data` checks consistency between `country/*.json`, `regions/*.json`, `regionNames/*.json`, `geocode/*.json`, and the statically supported countries in `lib/region.js` and `lib/geocode.js`.

See [DATA_REQUIREMENTS.md](./DATA_REQUIREMENTS.md) for the country-data format and checklist.

Expand Down
1 change: 1 addition & 0 deletions lib/geocode.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ function coordinates(country, zipCode) {
}

module.exports = coordinates;
module.exports.availableCountries = Object.freeze([...availableCountries]);
1 change: 1 addition & 0 deletions lib/region.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,4 @@ class RegionIdentifier {
}

module.exports = RegionIdentifier;
module.exports.availableCountries = Object.freeze([...availableCountries]);
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"scripts": {
"test": "node --test",
"lint": "eslint .",
"validate:data": "node scripts/validate-data.js",
"format": "prettier --write .",
"format:check": "prettier --check ."
},
Expand Down
3 changes: 2 additions & 1 deletion regionNames/BEL.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"BE-BRU": "Brussels Hoofdstedelijk Gewest",
"BE-VGL": "Vlaams Gewest",
"BE-VLG": "Vlaams Gewest",
"BE-WAL": "Waals Gewest"
}
}
2 changes: 2 additions & 0 deletions regionNames/USA.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"US-CT": "Connecticut",
"US-DE": "Delaware",
"US-DC": "District of Columbia",
"US-FM": "Federated States of Micronesia",
"US-FL": "Florida",
"US-GA": "Georgia",
"US-GU": "Guam",
Expand All @@ -22,6 +23,7 @@
"US-LA": "Louisiana",
"US-ME": "Maine",
"US-MD": "Maryland",
"US-MH": "Marshall Islands",
"US-MA": "Massachusetts",
"US-MI": "Michigan",
"US-MN": "Minnesota",
Expand Down
2 changes: 1 addition & 1 deletion regions/RUS.json
Original file line number Diff line number Diff line change
Expand Up @@ -43723,6 +43723,6 @@
},
{
"region": "RU-YAN",
"list": [ ]
"list": []
}
]
Loading