Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Country and sub-division ISO code validation #112

Merged
merged 1 commit into from
Feb 15, 2024

Conversation

TheRBajaj
Copy link
Contributor

This PR adds validation to the definitions of isoCountryCodeAlpha2 and isoSubCountryCode properties in the admin schema.
Issue: https://github.com/OvertureMaps/schema-wg/issues/117

Testing

Tested by modifying examples and creating new counterexamples accordingly and running test script.

Details

The following validation was added to isoCountryCodeAlpha2
- "minLength": 2
- "maxLength": 2
- "pattern": "^[A-Z]{2}$"

The following validation was added to isoSubCountryCode
- "minLength": 4
- "maxLength": 6
- "pattern": "^[A-Z]{2}-[A-Z0-9]{1,3}$"
- This validation comes from the ISO reference guide: https://www.iso.org/obp/ui/en/#iso:std:iso:3166:-2:ed-4:v1:en
image

@TheRBajaj TheRBajaj added the bug Something isn't working label Jan 31, 2024
@TheRBajaj TheRBajaj self-assigned this Jan 31, 2024
Copy link
Collaborator

@vcschapp vcschapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent stuff. There's an issue with the names in the counterexamples, but other than that looks good.

@TheRBajaj TheRBajaj force-pushed the users/rbajajj/country_and_subdivision_code_validation branch from cc2fc2a to 0009aac Compare February 1, 2024 01:30
Copy link
Collaborator

@vcschapp vcschapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a second issue in a couple of counter-examples where they include a copy/pasted invalid defaultLanguage and the extExpectedErrors is testing the language issue, not the desired issue...

vcschapp
vcschapp previously approved these changes Feb 1, 2024
Copy link
Collaborator

@vcschapp vcschapp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        _,--',   _._.--._____
 .--.--';_'-.', ";_      _.,-'
.'--'.  _.'    {`'-;_ .-.>.'
      '-:_      )  / `' '=.
        ) >     {_/,     /~)
snd     |/               `^ .'

@vcschapp
Copy link
Collaborator

vcschapp commented Feb 1, 2024

🚨 This is behind the schema freeze, so we'll have to wait to merge it to dev. 🚨

@vcschapp vcschapp changed the title Country and sub-divison iso code validation 🚨DO NOT MERGE UNTIL 2/15 🚨 Country and sub-division ISO code validation Feb 1, 2024
jwass
jwass previously approved these changes Feb 2, 2024
Copy link
Collaborator

@jwass jwass left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved for me. But would prefer removing min/max length if they're not needed since the pattern already dictates that.

schema/admins/defs.yaml Show resolved Hide resolved
Copy link
Collaborator

@jenningsanderson jenningsanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — Agree with @jwass, min/max length seems unnecessary if it' always 2 upper-case letters as demanded by the regex.

Copy link
Collaborator

@TristanDiet-TomTom TristanDiet-TomTom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, would leave the Length fields next to the pattern fields.

schema/admins/defs.yaml Show resolved Hide resolved
@TheRBajaj TheRBajaj force-pushed the users/rbajajj/country_and_subdivision_code_validation branch from 64835c5 to fd051b2 Compare February 15, 2024 21:20
@vcschapp vcschapp merged commit 554080b into dev Feb 15, 2024
2 checks passed
@vcschapp
Copy link
Collaborator

Doing a rebase and merge as this is a well-approved PR.

@vcschapp vcschapp deleted the users/rbajajj/country_and_subdivision_code_validation branch February 15, 2024 21:29
Copy link
Contributor

@marinrelatic marinrelatic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@vcschapp vcschapp changed the title 🚨DO NOT MERGE UNTIL 2/15 🚨 Country and sub-division ISO code validation Country and sub-division ISO code validation Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Admins bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants