pySHACL icon indicating copy to clipboard operation
pySHACL copied to clipboard

Failed to catch violations with properties that are not defined

Open mhoangvslev opened this issue 1 year ago • 8 comments

Given the datashape below, which is a json-ld markup:

{
    "@context": "http://schema.org",
    "@type": "Product",
    "@id": "https://www.slimmingeats.com/blog/hoisin-chicken-actifry-stove-top",
    "name": "Hoisin Chicken (Actifry or Stove top) | Slimming Eats",
    "description": "Heavenly Tender Hoisin Chicken - a quick simple dish that is ready in less than 20 minutes and can be cooked in an Actifry or on the Stove Top. Gluten Free, Dairy Free, Slimming Eats and Weight Watchers friendly.",
    "url": "https://www.slimmingeats.com/blog/hoisin-chicken-actifry-stove-top",
    "image": "https://www.slimmingeats.com/blog/wp-content/uploads/2016/06/hoisin-chicken-24-480x480.jpg",
    "brand": {
        "@type": "Brand",
        "name": "Slimming Eats"
    },
    "aggregateRating": {
        "@type": "AggregateRating",
        "ratingValue": 5.0,
        "reviewCount": 16
    },
    "offers": {
        "@type": "Offer",
        "price": 0.0,
        "priceCurrency": "USD",
        "availability": "http://schema.org/InStock"
    },
    "recipeCategory": "Main Dish",
    "recipeCuisine": "Chinese",
    "cookTime": "PT26M",
    "nutrition": {
        "@type": "NutritionInformation",
        "calories": "225",
        "totalFat": "2.8g",
        "saturatedFat": "0.1g",
        "cholesterol": "95mg",
        "sodium": "403mg",
        "carbohydrates": "10.3g",
        "fiber": "1.2g",
        "sugar": "5.5g",
        "protein": "39.2g"
    },
  "pouet": "pouet"
}

Given the shape graph, and the ontology, nutrition not being a property of Product or Thing, I expect a violation but there wasn't any.

I ran using:

pyshacl -e schemaorg-all-http.ttl -s schemaorg-datashapes.ttl -a -im -df json-ld test.json

I added sh:closed true to Thing but I encounter inheritance issues as discussed #167, #141.

I tried to follow the recommendation here but then pySHACL reports error:

Validator encountered a Constraint Load Error:
Cannot select a validator to use, according to the rules.
For reference, see https://www.w3.org/TR/shacl/#constraint-components-validators%     

mhoangvslev avatar Nov 15 '23 15:11 mhoangvslev