bdq icon indicating copy to clipboard operation
bdq copied to clipboard

TG2-VALIDATION_COUNTRYCODE_STANDARD

Open iDigBioBot opened this issue 7 years ago • 42 comments

TestField Value
GUID 0493bcfb-652e-4d17-815b-b0cce0742fbe
Label VALIDATION_COUNTRYCODE_STANDARD
Description Is the value of dwc:countryCode a valid ISO 3166-1-alpha-2 country code?
TestType Validation
Darwin Core Class dcterms:Location
Information Elements ActedUpon dwc:countryCode
Information Elements Consulted
Expected Response EXTERNAL_PREREQUISITES_NOT_MET if the bdq:sourceAuthority is not available; INTERNAL_PREREQUISITES_NOT_MET if the dwc:countryCode is bdq:Empty; COMPLIANT if dwc:countryCode can be unambiguously interpreted as a valid ISO 3166-1-alpha-2 country code in the bdq:sourceAuthority; otherwise NOT_COMPLIANT
Data Quality Dimension Conformance
Term-Actions COUNTRYCODE_STANDARD
Parameter(s)
Source Authority bdq:sourceAuthority default = "ISO 3166 Country Codes" {[https://www.iso.org/iso-3166-country-codes.html]} {ISO 3166-1-alpha-2 Country Code search [https://www.iso.org/obp/ui/#search]}
Specification Last Updated 2024-09-19
Examples [dwc:countryCode="GL": Response.status=RUN_HAS_RESULT, Response.result=COMPLIANT, Response.comment="dwc:countryCode is a valid ISO (ISO 3166-1-alpha-2 country codes) value"]
[dwc:countryCode="GRL": Response.status=RUN_HAS_RESULT, Response.result=NOT_COMPLIANT, Response.comment="dwc:countryCode is NOT a valid ISO (ISO 3166-1-alpha-2 country codes) value"]
Source TG2
References
  • ISO (n.dat.) ISO 3166 Country Codes. https://www.iso.org/iso-3166-country-codes.html
  • ISO (n.dat) 3166-1 alpha-2. https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
  • DataHub (2018) List of all countries with their two digit codes (ISO 3166-1). https://datahub.io/core/country-list
  • Chapman AD and Wieczorek JR (2020) Georeferencing Best Practices. Copenhagen: GBIF Secretariat. https://doi.org/10.15468/doc-gg7h-s853
Example Implementations (Mechanisms)
Link to Specification Source Code
Notes Locations outside of a jurisdiction covered by a country code may have a value in the field dwc:countryCode, the ISO user defined codes include XZ used by the UN for installations on the high seas and suitable for a marker for the high seas. Also available in the ISO user defined codes is ZZ, used by GBIF to mark unknown countries. This test should accept both XZ and ZZ as COMPLIANT country codes. This test must return NOT_COMPLIANT if there is leading or trailing whitespace or there are leading or trailing non-printing characters.

iDigBioBot avatar Jan 05 '18 15:01 iDigBioBot

Comment by Lee Belbin (@Tasilee) migrated from spreadsheet: Added post scoring for consistency

iDigBioBot avatar Jan 05 '18 15:01 iDigBioBot

Question from Gainesville meeting: what about records outside of country jurisdiction (e.g. Hugh seas). If material is from high seas - country code should be empty. Description altered to: If the dwc:countryCode contains a value but that value is not a valid ISO Code. Pass description is EMPTY if has a valid ISO Code.

We need a standard formalisation of what we mean by "EMPTY" which includes Empty, NULL, /N etc. Use EMPTY in all caps

ArthurChapman avatar Jan 16 '18 14:01 ArthurChapman

This test should not be parameterized. Different users will not wish to apply different ISO country codes. The parameterized resource that provides a service for country code lookup is one (which we could recommend, though I suggest not, rather just mention) way of implementing this test, however most implementors will almost certainly want to work with a local data structure that holds the short list of valid country codes rather than making requests to a service on each data record. This parameter is (1) straying too far into forcing a particular form of implementation on implementors, and (2) requiring a parameterized version of the test when none is needed as all use cases refer to the same ISO country code list.

chicoreus avatar Aug 20 '19 15:08 chicoreus

I have no idea why this is paramaterized. Particularly when the description says "dwc:countryCode is a valid ISO (ISO 3166-1-alpha-2 country codes)" @tucotuco - you paramaterized this - what was the thinking behind that?

ArthurChapman avatar Aug 20 '19 21:08 ArthurChapman

I concur that this test should not be parametrized.

tucotuco avatar Sep 05 '19 16:09 tucotuco

Removed paramaterized, added new references (Is the one I have listed as bbq:sourceAuthority - the best one here?)

ArthurChapman avatar Sep 05 '19 23:09 ArthurChapman

To me, the best source is https://restcountries.eu/#api-endpoints-list-of-codes, simply because they have an API. I don't think it will matter too much. This is a straightforward controlled vocabulary.

tucotuco avatar Sep 06 '19 18:09 tucotuco

@tucotuco: Agreed.

Tasilee avatar Sep 08 '19 22:09 Tasilee

The assertion about external prerequisites not met in the specification is probably confusing in the absence of a defined source authority service.

We should probably note that implementers may use a service to obtain country codes (best implementation is probably for code to download and cache a list, e.g. the json copy from https://datahub.io/core/country-list) rather than making a service call for each run of the test. With a cached copy of country codes, implementors could have the choice of returning EXTERNAL_PREREQUISITES_NOT_MET if unable to refresh the cached copy on start up, or just using the cached copy, with how old the cache may be at a maximum being up to them. This could go in the notes rather than the specification (expected response).

Also noting that https://restcountries.eu/#api-endpoints-list-of-codes has been unresponsive of late.

chicoreus avatar Feb 18 '22 16:02 chicoreus

Thanks @chicoreus. Local caching is likely to apply to a number of bdq:sourceAuthority. Why don't we just use the standard phrase "EXTERNAL_PREREQUISITES_NOT_MET if the bdq:SourceAuthority is not available", define our default in the Notes and leave the implementation up to the implementer?

Tasilee avatar Feb 21 '22 02:02 Tasilee

"not available" seems like it covers the eventualities well. I like the solution.

tucotuco avatar Feb 21 '22 03:02 tucotuco

I agree @tucotuco

ArthurChapman avatar Feb 21 '22 20:02 ArthurChapman

Edited accordingly.

Tasilee avatar Feb 21 '22 22:02 Tasilee

I suggest the Description:

'Is the value of dwc:countryCode a valid ISO 3166-1-alpha-2 country code?'

in place of:

'Is the value of dwc:countryCode a valid ISO country code value?'

tucotuco avatar Mar 31 '22 01:03 tucotuco

Changed Description

Does the value of dwc:country occur as the equivalent of a nation in the bdq:sourceAuthority?

to

Does the value of dwc:countryCode occur as the equivalent of a nation in the bdq:sourceAuthority?

Tasilee avatar Apr 03 '22 22:04 Tasilee

That is not the same as the ER

Should be

Is the value of dwc:countryCode a valid ISO 3166-1-alpha-2 country code value?

ArthurChapman avatar Apr 03 '22 22:04 ArthurChapman

I agree and wonder how this was reverted.

Tasilee avatar Apr 03 '22 22:04 Tasilee

Added to Notes: "This test will fail if there are leading or trailing white space or non-printing characters."

Tasilee avatar Sep 12 '22 02:09 Tasilee

See comments under #48. If we agree to a change there, then this one should also be changed to

EXTERNAL_PREREQUISITES_NOT_MET if a configured service for checking ISO 3166 country codes is not available; INTERNAL_PREREQUISITES_NOT_MET if the dwc:countryCode was EMPTY; COMPLIANT if it can be unambiguously interpreted as a ISO 3166-1-alpha-2; otherwise NOT_COMPLIANT

and remove reference to bdq:sourcrAuthority under source:Authority

ArthurChapman avatar Jun 29 '23 23:06 ArthurChapman

I agree, and wouldn't this apply also to

#38, #133 bdq:sourceAuthority default = "Creative Commons" [https://creativecommons.org/]

#62, #48

bdq:sourceAuthority is "ISO 3166-1-alpha-2" [https://restcountries.eu/#api-endpoints-list-of-codes, https://www.iso.org/obp/ui/#search]

and possibly a few more?

Tasilee avatar Jun 29 '23 23:06 Tasilee

References need checking as restcountries.eu is no longer there. We will need a link check through all of the issues.

Tasilee avatar Jun 30 '23 00:06 Tasilee

Suggested possibly using https://rapidapi.com/ajayakv/api/rest-countries - awaiting feedback

ArthurChapman avatar Jun 30 '23 00:06 ArthurChapman

Updated References

ArthurChapman avatar Jul 03 '23 21:07 ArthurChapman

Added Source Authority value as " {bdq:sourceAuthority = ISO 3166-1-alpha-2} { Country codes [https://dwc.tdwg.org/terms/#dwc:basisOfRecord]](https://www.iso.org/obp/ui/#search]}"

for now.

Tasilee avatar Jul 04 '23 00:07 Tasilee

Amended Source Authority to align with @chicoreus suggested syntax

{bdq:sourceAuthority = ISO 3166-1-alpha-2} { Country codes [https://www.iso.org/obp/ui/#search]}

to

bdq:sourceAuthority default = "ISO 3166-1-alpha-2 country codes" { [https://www.iso.org/obp/ui/#search]}

Tasilee avatar Jul 04 '23 22:07 Tasilee

Corrected syntax on Source Authority

Tasilee avatar Jul 10 '23 20:07 Tasilee

Changed Expected response from

EXTERNAL_PREREQUISITES_NOT_MET if a configured service for checking ISO 3166 country codes is not available; INTERNAL_PREREQUISITES_NOT_MET if the dwc:countryCode was EMPTY; COMPLIANT if it can be unambiguously interpreted as a ISO 3166-1-alpha-2; otherwise NOT_COMPLIANT

to

EXTERNAL_PREREQUISITES_NOT_MET if a configured service for checking ISO 3166 country codes is not available; INTERNAL_PREREQUISITES_NOT_MET if the dwc:countryCode was EMPTY; COMPLIANT if it can be unambiguously interpreted as an ISO 3166-1-alpha-2 country code; otherwise NOT_COMPLIANT

and removed reference to bdq:sourceAuthority in Source Authority

Tasilee avatar Jul 10 '23 22:07 Tasilee

Due to recent discussions, changed

EXTERNAL_PREREQUISITES_NOT_MET if a configured service for checking ISO 3166 country codes is not available; INTERNAL_PREREQUISITES_NOT_MET if the dwc:countryCode was EMPTY; COMPLIANT if it can be unambiguously interpreted as a ISO 3166-1-alpha-2 country code; otherwise NOT_COMPLIANT

to

EXTERNAL_PREREQUISITES_NOT_MET if bdq:sourceAuthority is not available; INTERNAL_PREREQUISITES_NOT_MET if the dwc:countryCode was EMPTY; COMPLIANT if dwc:countryCode can be unambiguously interpreted as an ISO 3166-1-alpha-2 country code; otherwise NOT_COMPLIANT

and Source Authority from blank to

bdq:sourceAuthority default = "ISO 3166 Country Codes" {[https://www.iso.org/iso-3166-country-codes.html]} {ISO 3166-1-alpha-2 Country Code search [https://www.iso.org/obp/ui/#search]}

and updated Specification Last Updated

Tasilee avatar Jul 16 '23 23:07 Tasilee

I'm making a start on splitting bdqffdq:Information Elements into "Information Elements ActedUpon" and "Information Elements Consulted". I am working through the tests in numerical sequence. Please check.

Tasilee avatar Sep 16 '23 03:09 Tasilee

Does that affect Specification Last Updated?

ArthurChapman avatar Sep 16 '23 21:09 ArthurChapman