openactive / data-model-validator

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

A few bugs #79

Closed nickevansuk closed 6 years ago

nickevansuk commented 6 years ago

Just validating the following feed (which should pass), and found 16 errors and 17 warnings. As far as I can see it should result in 0 errors and 5 warnings.

JSON as follows:

{
  "@context": "https://www.openactive.io/ns/oa.jsonld",
  "type": "Event",
  "id": "https://example.com/api/sessions/emd-123",
  "name": "daoist Yoga and tai chi",
  "level": [ "Beginners", "Intermediate", "Advanced" ],
  "maximumAttendeeCapacity": 20,
  "accessibilitySupport": [
    {
      "type": "Concept",
      "id": "https://example.com/api/accessibilitySupport/#1393f2dc-3fcc-4be9-a99f-f1e51f5ad277",
      "prefLabel": "Visual impairment",
      "inScheme": "https://example.com/api/accessibilitySupport"
    }
  ],
  "accessibilityInformation": "Some clothes",
  "attendeeInstructions": "Clothing instructions: Sportswear/gym clothes, Comfortable loose clothing, Trainers. No equipment required.",
  "description": "Very friendly welcoming class to learn daoist chi gong, daoist yoga, daoist breathing, massage, tai chi forms and daoist soft self defence.",
  "identifier": 61655,
  "activity": [
    {
      "type": "Concept",
      "id": "http://openactive.io/activity-list/#2a41c553-84be-4970-b3d0-42f9ef6bd9a4",
      "prefLabel": "Road Cycling",
      "inScheme": "http://openactive.io/activity-list/activity-list.jsonld"
    }
  ],
  "category": [
    {
      "type": "Concept",
      "id": "https://example.com/api/categories/#33967d33-0e5c-4a03-b0a9-7f1cf6b28d1b",
      "prefLabel": "Strength and Conditioning",
      "inScheme": "https://example.com/api/categories"
    }
  ],
  "genderRestriction": "http://openactive.io/ns#None",
  "ext:specialRequirements": [
    {
      "type": "Concept",
      "id": "https://example.com/api/specialRequirements/#22584a2a-fafc-4710-863c-8a1fc3f96b2c",
      "prefLabel": "Adult Education",
      "inScheme": "https://example.com/api/specialRequirements"
    }
  ],
  "leader": [
    {
      "type": "Person",
      "name": "Mr John Smith",
      "gender": "http://schema.org/Male",
      "identifier": 24633
    }
  ],
  "url": "https://london.lishi.org/classes/hackney",
  "location": {
    "type": "Place",
    "name": "The Bath House, ",
    "address": {
      "type": "PostalAddress",
      "streetAddress": "76 Shacklewell Lane",
      "addressRegion": "Hackney, Dalston",
      "addressLocality": "London",
      "postalCode": "E8 2EY",
      "addressCountry": "GB"
    },
    "geo": {
      "type": "GeoCoordinates",
      "latitude": 51.552079,
      "longitude": -0.071399
    },
    "identifier": 59168,
    "amenityFeature": [
      {
        "name": "Changing Facilities",
        "value": true,
        "type": "ChangingRooms"
      },
      { "name": "Showers", "value": false, "type": "Showers" },
      { "name": "Lockers", "value": true, "type": "Lockers" },
      { "name": "Towels", "value": false, "type": "Towels" },
      { "name": "Creche", "value": false, "type": "Creche" },
      { "name": "Parking", "value": true, "type": "Parking" }
    ]
  },
  "eventSchedule": {
    "type": "Schedule",
    "startDate": "2018-01-01",
    "endDate": "2018-12-31",
    "repeatFrequency": "P1W",
    "byDay": [ "http://schema.org/Friday" ],
    "startTime": "19:00Z",
    "endTime": "20:00Z",
    "duration": "P1W"
  },
  "subEvent": [
    {
      "type": "Event",
      "startDate": "2018-07-25T19:00:00Z",
      "endDate": "2018-07-25T20:00:00Z",
      "duration": "PT1H",
      "maximumAttendeeCapacity": 20,
      "remainingAttendeeCapacity": 4,
      "eventStatus": "http://schema.org/EventScheduled"
    }
  ],
  "ageRange": { "type": "QuantitativeValue", "minValue": 18, "maxValue": 55 },
  "offers": [
    {
      "type": "Offer",
      "acceptedPaymentMethod": [ "http://purl.org/goodrelations/v1#Cash" ],
      "price": 7,
      "priceCurrency": "GBP",
      "eligibleCustomerType": [ "http://openactive.io/ns#Member" ],
      "url": "https://www.example.com/direct/booking/link"
    }
  ],
  "organizer": [
    {
      "type": "Organization",
      "telephone": "01344 874787",
      "name": "The Fitness League"
    }
  ],
  "image": [
    {
      "type": "ImageObject",
      "url": "http://www.fusion-lifestyle.com/media/global/activities/thumb/body_pump_fitness_2016_04_14_15_27_27.jpg",
      "thumbnail": [
        {
          "type": "ImageObject",
          "url": "http://www.fusion-lifestyle.com/media/global/activities/thumb/body_pump_fitness_2016_04_14_15_27_27.jpg"
        }
      ]
    }
  ]
}

Breakdown as follows:

identifier Invalid type, expected 'http://schema.org/Text' but found 'http://schema.org/Integer' ERROR

identifier should always allow both

identifier Required field is missing. ERROR

Not required

identifier Required field is missing. ERROR

Not required

identifier Required field is missing. ERROR

Not required

identifier Required field is missing. ERROR

Not required

identifier Invalid type, expected 'http://schema.org/Text' but found 'http://schema.org/Integer' ERROR

identifier should always allow both

url Required field is missing. ERROR

Not required

identifier Invalid type, expected 'http://schema.org/Text' but found 'http://schema.org/Integer' ERROR

identifier should always allow both

amenityFeature Invalid type, expected 'ArrayOf#LocationFeatureSpecification' but found 'ArrayOf#{ChangingRooms,Showers,Lockers,Towels,Creche,Parking}' ERROR

Rule seems broken, this should pass

byDay This value supplied is not in the allowed values for this field ERROR

Rule seems broken, this should pass

id Required field is missing. ERROR

Not required for non-bookable

id Required field is missing. ERROR

Not required for non-bookable

name Required field is missing. ERROR

Not required for single offer

thumbnail Invalid type, expected '#ImageObject' but found 'ArrayOf#ImageObject' ERROR

Should be array

ext:specialRequirements The validator does not currently check experimental fields WARNING

Good message

eventStatus Recommended field is missing. WARNING

Is present on subEvent so this should not be a warning

activity Could not check activities are in activity list - could not find activity list file WARNING

This is a valid activity

gender This field is not defined in the specification WARNING

Should be included

description (on Person) Recommended field is missing. WARNING

Unusual to have this data - shouldn't be recommended

id Recommended field is missing. WARNING

Unusual to have this data (should it not be recommended? or can I dismiss this message? or?)

description Recommended field is missing. WARNING

Unusual to have this data (should it not be recommended? or can I dismiss this message? or?)

image Recommended field is missing. WARNING

Unusual to have this data (should it not be recommended? or can I dismiss this message? or?)

telephone Recommended field is missing. WARNING

Good message

openingHoursSpecification Recommended field is missing. WARNING

Unusual to have this data (should it not be recommended? or can I dismiss this message? or?)

acceptedPaymentMethod This field is not defined in the specification WARNING

Should be allowed as per schema.org

eligibleCustomerType This field is not defined in the specification WARNING

Should be allowed as per schema.org

url This field is not defined in the specification WARNING

Should be allowed as per schema.org, for the booking URL for click-through booking

ageRange Recommended field is missing. WARNING

Good message

telephone This field is not defined in the specification WARNING

Should be, is part of schema.org

description Recommended field is missing. WARNING

Good message

logo Recommended field is missing. WARNING

Good message

petewalker commented 6 years ago

I've revalidated, and got the following output:

nickevansuk commented 6 years ago

Responses below:

ERROR: $.leader[0].id - Required field is missing. ERROR: $.leader[0].identifier - Invalid type, expected 'http://schema.org/Text' but found 'http://schema.org/Integer' ERROR: $.location.identifier - Invalid type, expected 'http://schema.org/Text' but found 'http://schema.org/Integer' (x2) identifier should always allow both

these are both correct according to the spreadsheet - have raised as comments on there

I saw @ldodds has allowed both for some already, this should just be applied to all identifiers

ERROR: $.eventSchedule.byDay - This value supplied is not in the allowed values for this field This is a bug - it's not validating arrays properly when they have a set list of options (#88)

ERROR: $.subEvent[0].id - Required field is missing. ERROR: $.offers[0].name - Required field is missing. ERROR: $.organizer[0].id - Required field is missing. ERROR: $.image[0].thumbnail - Invalid type, expected '#ImageObject' but found 'ArrayOf#ImageObject' Should be array

this actually isn't even in the OA spec - @ldodds - should it be?

This is a debate am currently having with @ldodds, whether Props in common use make it into our profile. The criteria seems a little subjective at the moment. I’m keen to see us recognise these.

WARNING: $.ext:specialRequirements - The validator does not currently check experimental fields WARNING: $.eventStatus - Recommended field is missing. Is present on subEvent so this should not be a warning

can an event really inherit from its child?! It's not clear this is the case in the current specification - @ldodds ?

What I mean is that the eventStatus is only relevant at the subEvent level, or if this event doesn’t have subEvents then is on the parent. You likely wouldn’t cancel the parent, you’d just delete it, you’d cancel individual occurrences. (Ref: issue to mandate subEvent in all cases)

WARNING: $.activity - Could not check activities are in activity list - could not find activity list file This is a valid activity

This is a bug! (#89)

WARNING: $.leader[0].gender - This field is not defined in the specification WARNING: $.location.id - Recommended field is missing. WARNING: $.location.url - Recommended field is missing. WARNING: $.location.description - Recommended field is missing. WARNING: $.location.image - Recommended field is missing. (x4) Unusual to have this data (last 4) (should it not be recommended? or can I dismiss this message? or?)

It's recommended currently in the spec. I'm unsure what you want by dismissing?

Ideally if i’ve been told about a warning that’s not relevant to me (as some warnings are asking for data I just don’t have, or flagging issues that aren’t relevant), I could hide that specific warning (even just temporarily for that browser session) and focus on the messages I can do something about

WARNING: $.location.telephone - Recommended field is missing. WARNING: $.location.openingHoursSpecification - Recommended field is missing. Unusual to have this data (should it not be recommended? or can I dismiss this message? or?)

It's recommended currently in the spec. I'm unsure what you want by dismissing?

WARNING: $.offers[0].acceptedPaymentMethod - This field is not defined in the specification WARNING: $.offers[0].eligibleCustomerType - This field is not defined in the specification (x2) Should be allowed as per schema.org

See #5 - @ldodds has asked that fields not explicitly in the OA spec still raise a warning. We'll make the message nicer for those in schema.org

Depending on the outcome of our discussion about the objective criteria used to included commonly used props in our profile, i we are being mega parsimonious with which props get in, suggest this is a Tip rather than a warning. Otherwise it sends the wrong message to publishers.

WARNING: $.offers[0].id - Recommended field is missing. WARNING: $.offers[0].ageRange - Recommended field is missing. WARNING: $.organizer[0].telephone - This field is not defined in the specification Should be allowed as per schema.org

See #5 - @ldodds has asked that fields not explicitly in the OA spec still raise a warning. We'll make the message nicer for those in schema.org

WARNING: $.organizer[0].url - Recommended field is missing. WARNING: $.organizer[0].description - Recommended field is missing. WARNING: $.organizer[0].logo - Recommended field is missing. TIP: $.eventStatus - Data consumers will assume the event status is scheduled if not specified or invalid

MelanieAbraham commented 6 years ago

@nickevansuk I've rerun this code in the latest staging version and it now has 8 errors (up from 2 on the latest released version of the validator) and 19 warnings - are there still changes to be made?

nickevansuk commented 6 years ago

Still issues here, have re-raised with an updated sample to reflect recent spec changes: https://github.com/openactive/data-model-validator/issues/217