Skip to content

Add an optional country field to places (step 1 of #288) - #325

Merged
AnayDhawan merged 2 commits into
StudentSuite:mainfrom
propcgamer20-png:feat/place-country-field
Oct 30, 2026
Merged

AnayDhawan merged 2 commits into
StudentSuite:mainfrom
propcgamer20-png:feat/place-country-field

Conversation

@propcgamer20-png

Copy link
Copy Markdown
Member

What this changes

Part of #288, step 1 of the five the issue lays out ("Add an optional country to the schema, the Place type and the validator. Document it."). The backfill, making the field required, the API parameter and the map filter are later PRs, so this does not use "Fixes".

  • data/places.schema.json: new optional country property, a string matching ^[A-Z]{2}$, described as an ISO 3166-1 alpha-2 code (the same codes competitions use for region).
  • src/lib/types.ts: Place.country?: string.
  • scripts/lib/data-validation.mjs: isCountryCode(value) (exactly two capital letters).
  • scripts/validate-places.mjs: errors when a record has a country that is not a two-letter upper-case code, naming the record and the value.
  • data/CONTRIBUTING.md: documents the field next to city and says it becomes required after the backfill.
  • src/lib/country-code.test.ts (new): accepts IN, GB, KE, US; rejects india, in, In, IND, empty, non-strings.

No data file changes, so every existing record stays valid.

Proof

Acceptance criterion for this step, tried on a throwaway edit of mum-library-01 (restored afterwards):

"country": "india"  ->  ERROR library.json[0] (id: mum-library-01): country must be a two-letter upper-case ISO 3166-1 alpha-2 code like "IN", got "india"   (validation failed)
"country": "IN"     ->  Validation passed

npm run validate passes on the branch as is. npm run lint, npm run typecheck, npm run format:check are clean; npm run test:unit: 603 passed.

The validator checks the shape only (two capital letters). It does not check that the code is an assigned ISO code, so ZZ would pass; I kept that out of step 1 and can add an allowlist when the field becomes required if you want one.

Type of change

  • Code or fix
  • New public place(s)
  • New or updated benefit guide
  • New or updated resource link
  • Docs

@vercel

vercel Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

@propcgamer20-png is attempting to deploy a commit to the studentsuite Team on Vercel.

A member of the Team first needs to authorize it.

@AnayDhawan
AnayDhawan merged commit e5d3826 into StudentSuite:main Oct 30, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants