openactive / data-model-validator

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

Internal Validator Error when `activity` contains null fields #416

Open lukehesluke opened 2 years ago

lukehesluke commented 2 years ago

Reproduce by putting this JSON into https://validator.openactive.io/:

{
  "@context": "https://openactive.io/",
  "url": "https://example.com/id",
  "id": "https://example.com/url",
  "@type": "SessionSeries",
  "activity": [
    {
      "@type": "Concept",
      "id": null,
      "inScheme": "https://openactive.io/activity-list",
      "prefLabel": null
    }
  ],
  "organizer": {
    "id": "https://example.com/org-id",
    "@type": "Organization",
    "name": "Lorem Ipsum",
    "url": "https://example.com/org-url"
  },
  "duration": "PT1H",
  "name": "Dolor sit amet",
  "location": {
    "@type": "Place",
    "url": "https://example.com/loc-url",
    "name": "consectetur adipiscing elit",
    "id": "https://example.com/loc-id",
    "address": {
      "@type": "PostalAddress",
      "addressCountry": "GB",
      "streetAddress": "Duis vestibulum",
      "addressLocality": "velit nulla",
      "addressRegion": "eu ornare",
      "postalCode": "AB1 2CD"
    },
    "geo": {
      "@type": "GeoCoordinates",
      "latitude": 0,
      "longitude": 0
    }
  },
  "eventSchedule": [
    {
      "@type": "PartialSchedule",
      "startDate": "2001-01-01",
      "endDate": "2001-01-20"
    }
  ],
  "offers": [
    {
      "@type": "Offer",
      "price": 0,
      "priceCurrency": "GBP"
    }
  ]
}

You'll see this error:

Screenshot 2022-10-19 at 16 54 26

Internal validator error: Cannot read property 'toLowerCase' of null

This error hides the actual issue, which is that .activity[].id and .prefLabel are required