Skip to content

Conversation

@Ndpnt
Copy link
Contributor

@Ndpnt Ndpnt commented Feb 11, 2025

As example, for this metadata file:

id: demo
name: Demo
tagline: 13
description: |
  The **Demo** collection tracks changes to the terms of use of services used by Open Terms Archive.
  
  This provides a reference collection for best practices and enables the Open Terms Archive Core Team to be a user of the software it produces.
dataset: https://github.com/OpenTermsArchive/demo-versions/releases
declarations: https://github.com/OpenTermsArchive/demo-declarations
versions: https://github.com/OpenTermsArchive/demo-versions
snapshots: https://github.com/OpenTermsArchive/demo-snapshots
donations: https://opencollective.com/opentermsarchive
logo: https://opentermsarchive.org/images/collections/demo.png
languages: [EN]
extraPropsAtRoot: unwanted
jurisdictions: [US-CA]
trackingPeriods:
  - startDate: 2023-01-01
    schedule: "30 */1s2 * * *"
    serverLocation: Roubaix, FR
    extraProps: unwanted
governance:
  Ministry for Europe and Foreign Affairs:
    url: www.diplomatie.gouv.fr
    logo: https://opentermsarchive.org/images/contributors/meae.png
    roles: [host, sponsor]
  Open Terms Archive:
    url: https://opentermsarchive.org
    logo: https://opentermsarchive.org/images/logo/logo-open-terms-archive-black.png
    roles: [administrator, unknown-role, maintainer]

The command returns this output:

↳ npm run metadata:validate

> @opentermsarchive/[email protected] metadata:validate
> node bin/ota.js validate metadata



  Metadata file validation
    1) is valid


  0 passing (66ms)
  1 failing

  1) Metadata file validation
       is valid:
     Error:
- /root: Found unexpected property "extraPropsAtRoot"
- /tagline: "13" must be string
- /languages/0: "EN" must be a valid ISO 639-1 language code (two lowercase letters, e.g., "en", "fr")
- /trackingPeriods/0: Found unexpected property "extraProps"
- /trackingPeriods/0/schedule: "30 */1s2 * * *" must be a valid cron expression (see https://en.wikipedia.org/wiki/Cron#Cron_expression)
- /governance/Ministry for Europe and Foreign Affairs/url: "www.diplomatie.gouv.fr" must match format "uri"
- /governance/Open Terms Archive/roles/1: "unknown-role" must be equal to one of the allowed values "host", "administrator", "curator", "maintainer", "sponsor"
      at Context.<anonymous> (file:///Users/ndpnt/Workspace/OTA/engine/scripts/metadata/index.mocha.js:83:11)
      at process.processImmediate (node:internal/timers:478:21)

@Ndpnt Ndpnt requested a review from clementbiron February 11, 2025 13:48
@Ndpnt Ndpnt force-pushed the validate-metadata-file branch from 895601b to d773c16 Compare February 11, 2025 13:55
process.on('unhandledRejection', reason => {
// Re-throw them so that the validation command fails in these cases (for example, if there is a syntax error when parsing JSON declaration files)
throw reason;
process.on('unhandledRejection', reason => { // Mocha catches unhandled rejection from the user code and re-emits them to the process (see https://github.com/mochajs/mocha/blob/master/lib/runner.js#L198)
Copy link
Member

Choose a reason for hiding this comment

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

The line number #L198 referred to here does not agree with the version of Mocha used and there is no guarantee that this link will work over time.

@Ndpnt Ndpnt merged commit 3888b01 into main Feb 17, 2025
8 checks passed
@Ndpnt Ndpnt deleted the validate-metadata-file branch February 17, 2025 08:01
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.

3 participants