Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema Validation #10

Open
ethernetdan opened this issue May 23, 2016 · 2 comments
Open

Schema Validation #10

ethernetdan opened this issue May 23, 2016 · 2 comments

Comments

@ethernetdan
Copy link

It doesn't appear like there is a way to validate that a piece of conforms to a schema.

I would expect it to behave similarly to this tool and check that the provided schema(s) match the fields used: https://search.google.com/structured-data/testing-tool

Not sure how much work this would be to implement but I'm happy to lend a hand.

@kazarena
Copy link
Owner

@ethernetdan This sounds like a very good idea! Few observations:

  • JSON-LD context doesn't provide enough information about what may or may not be used/included into specific field. You will need to use a vocabulary (like http://schema.org/docs/schema_org_rdfa.html - apologies, I can't find the proper RDF representation right now) which may or may not be available for a specific context. I.e. it can't tell that the expected type of aggregateRating field is AggregateRating:
"aggregateRating": {
    "@type": "AggregateRating",
    "ratingValue": "4.5",
    "reviewCount": "276",
    "bestRating": "5",
    "worstRating": "1"
  }

This also may be an alreadt solved problem (for RDF). If that's the case, building a validator could be easy: use this library to transform JSON-LD into RDF quads and apply RDF based validation!

  • I would be cautious about making any alterations into the core of JSON-API operations provided by this library (if required for adding the validation logic), because it closely follows the standard and reference implementations.

Feel free to expand, I'm open to suggestions!

@bruth
Copy link

bruth commented Sep 27, 2016

@ethernetdan For schema validation, using json-schema. gojsonschema is a library for doing this in Go. You can use it to validate that a JSON-LD record is valid as well as the schemas themselves are valid.

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

No branches or pull requests

3 participants