Repository navigation
Add an optional country field to places (step 1 of #288) - #325
Merged
AnayDhawan merged 2 commits intoOct 30, 2026
Merged
Conversation
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. |
…th other validator changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Part of #288, step 1 of the five the issue lays out ("Add an optional
countryto the schema, thePlacetype 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 optionalcountryproperty, a string matching^[A-Z]{2}$, described as an ISO 3166-1 alpha-2 code (the same codes competitions use forregion).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 acountrythat is not a two-letter upper-case code, naming the record and the value.data/CONTRIBUTING.md: documents the field next tocityand says it becomes required after the backfill.src/lib/country-code.test.ts(new): acceptsIN,GB,KE,US; rejectsindia,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):npm run validatepasses on the branch as is.npm run lint,npm run typecheck,npm run format:checkare 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
ZZwould 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