Skip to content
Merged
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 data/places.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"city": {
"type": "string",
"minLength": 1,
"pattern": "^[a-z0-9]+(_[a-z0-9]+)*$",
"description": "Lowercase, underscore-separated slug, e.g. \"mumbai\", \"navi_mumbai\". Any city worldwide is welcome, not a fixed enum."
},
"lat": {
Expand Down
2 changes: 1 addition & 1 deletion data/places/library.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
"id": "xiamen-library-01",
"name": "厦门图书馆集美新城馆东南门",
"type": "library",
"city": "厦门",
"city": "xiamen",
"lat": 24.59441,
"lng": 118.05789,
"address": "福建省厦门市集美区诚毅中路380号",
Expand Down
8 changes: 4 additions & 4 deletions data/places/sat_centre.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
"id": "delhi-ncr-sat-01",
"name": "American Embassy School",
"type": "sat_centre",
"city": "new delhi",
"city": "new_delhi",
"lat": 28.598015,
"lng": 77.182659,
"address": "CHANDRAGUPTA MARG, CHANAKYAPURI, NEW DELHI, DELHI",
Expand All @@ -263,7 +263,7 @@
"id": "delhi-ncr-sat-02",
"name": "Amity International School",
"type": "sat_centre",
"city": "new delhi",
"city": "new_delhi",
"lat": 28.613895,
"lng": 77.209006,
"address": "SECTOR 7, PUSHP VIHAR, NEW DELHI, DELHI",
Expand All @@ -276,7 +276,7 @@
"id": "delhi-ncr-sat-03",
"name": "The British School",
"type": "sat_centre",
"city": "new delhi",
"city": "new_delhi",
"lat": 28.597247,
"lng": 77.180085,
"address": "DR. JOSE P. RIZAL MARG, CHANAKYAPURI, NEW DELHI, DELHI",
Expand Down Expand Up @@ -2330,7 +2330,7 @@
"id": "04489",
"name": "Academy at Palumbo",
"type": "sat_centre",
"city": "philadephia",
"city": "philadelphia",
"lat": 39.9400517,
"lng": -75.1615327,
"address": "1100 CATHARINE STREET",
Expand Down
13 changes: 13 additions & 0 deletions scripts/validate-places.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* - Unique id within each file and across all files
* - type is one of the schema's enum values
* - type matches the filename it lives in
* - city is a lowercase, underscore-separated slug
* - id matches the <city-prefix>-<type>-<number> convention, or is a bare
* numeric id (the College Board SAT centre code convention)
* - lat/lng are numbers within the schema's min/max bounds
Expand Down Expand Up @@ -43,6 +44,7 @@ const BOUNDS = {
maxLng: schema.properties.lng.maximum,
};
const GMAPS_RE = new RegExp(schema.properties.gmaps_link.pattern);
const CITY_SLUG_RE = new RegExp(schema.properties.city.pattern);

// <city-prefix>-<type>-<number>, allowing multi-segment city/type prefixes
// (e.g. "delhi-ncr-sat-01", "mum-airport-terminal-01"), or a bare numeric id
Expand Down Expand Up @@ -155,6 +157,17 @@ for (const file of files) {
);
}

// city must use the canonical lowercase, underscore-separated slug form
if (
r.city !== undefined &&
(typeof r.city !== "string" || !CITY_SLUG_RE.test(r.city))
) {
err(
loc,
`city must be a lowercase, underscore-separated slug, got ${JSON.stringify(r.city)}`,
);
}

// valid_till format, when present
if (r.valid_till !== undefined && !isRealIsoDate(r.valid_till)) {
err(loc, `valid_till must be a real ISO date (YYYY-MM-DD), got "${r.valid_till}"`);
Expand Down
2 changes: 1 addition & 1 deletion src/app/docs/(article)/places-api/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const FILTERS: { name: string; type: string; notes: string }[] = [
name: "city",
type: "string",
notes:
"Case-insensitive; spaces and hyphens are normalized to the dataset's underscore slugs (e.g. `New Delhi` matches `new delhi`). No matching city returns an empty `data` array.",
"Case-insensitive; spaces and hyphens are normalized to the dataset's underscore slugs (e.g. `New Delhi` matches `new_delhi`). No matching city returns an empty `data` array.",
},
{
name: "category",
Expand Down
Loading