openactive / data-model-validator

The OpenActive data model validator library
MIT License
1 stars 1 forks source link

Improve valid-model-type-rule to accept beta and schema.org types #358

Open nickevansuk opened 4 years ago

nickevansuk commented 4 years ago

The following error: Screenshot 2020-09-11 at 10 01 56

Is returned by the following data:

{
  "@context": [
    "https://openactive.io/",
    "https://openactive.io/ns-beta"
  ],
  "@id": "https://opensessions.io/API/rpde/session-series/2210",
  "url": "https://www.opensessions.io/#/Organisation/SessionDetail?OrganisationId=973&SessionId=2210",
  "@type": "Event",
  "beta:contactPoint": {
    "@type": "ContactPoint",
    "name": "Silvia",
    "email": "salsaysol@salsaysol.co.uk",
    "telephone": "01256389275"
  }
}

This error is incorrect, as there is no check being made against schema.org:

https://github.com/openactive/data-model-validator/blob/e63a1f6890425c287a1de09e1e75707e24e8df82/src/rules/core/valid-model-type-rule.js#L86-L100

valid-model-type-rule.js should be improved to actually check against schema.org and beta types, possibly using GraphHelper (for beta and other extensions) and DataModelHelper.getSchemaOrgVocab() (for schema.org) as in fields-not-in-model-rule.js.

An alternative approach would be to refactor the extensions and schema.org referenced contexts into models on the fly, using something similar to this or this, however this is a larger refactor.

civsiv commented 3 years ago

Have come across this error while trying use validator in the imin pipeline, would be great to fix!

nickevansuk commented 1 year ago

fields-not-in-model-rule.js should also be updated to accept beta, schema.org and any extension types specified in the @context