telicent-validation-tool
A library for validating data before it is brought in to Telicent CORE.
Install
pip install telicent-validation-tool
Usage
JSON Validation
The JSON validator loads a json-schema from a given file path, and uses the jsonschema library to validate the provided JSON.
from telicent_validation_tool import TelicentValidationError, validate_json
my_json: str = '{"name: "John Smith"}'
schema_path: str = '/path/to/schema.json'
try:
validate_json(my_json, schema_path)
except TelicentValidationError as e:
print(f"Validation error: {e}")
The JSON schema file will only be loaded from disk on the first validation to improve the performance of subsequent validations.
To force a validation to reload the schema file from disk, set force_reload=True.
validate_json(my_json, schema_path, force_reload=True)
SHACL Validation
The SHACL validator provides a wrapper around Telicent's own shacl-tool. It validates a rdf graph against the shacl and ontology triples of the base ontology being used and any domain specific extensions. For example, you might be using the FOAF base ontology but have extended some of the classes; for example:
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix myont: <http://example.com/ontology/my-domain-specific-ontology#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
myont:Child rdfs:subClassOf foaf:Person .
shacl_parts and ontology_parts are lists of paths to turtle files. This allows us to fuse shacl and ontology
files applicable to the graph requiring validation.
from rdflib import Graph, URIRef, Literal, XSD
from telicent_validation_tool import TelicentValidationError, validate_rdf_turtle
graph: Graph = Graph()
graph.add(
URIRef("http://example.com/data/nick_smith"),
URIRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
URIRef("http://example.com/ontology/my-domain-specific-ontology#Child")
)
graph.add(
URIRef("http://example.com/data/nick_smith"),
URIRef("http://xmlns.com/foaf/0.1/name"),
Literal("Nick Smith", datatype=XSD.string)
)
shacl_parts: list = [
'/path/to/foaf-base-ontology.shacl.ttl'
'/path/to/my-domain-specific.shacl.ttl'
]
ontology_parts: list = [
'/path/to/foaf-base-ontology.ttl'
'/path/to/my-domain-specific-ontology.ttl'
]
try:
validate_rdf_turtle(graph, shacl_parts, ontology_parts)
except TelicentValidationError as e:
print(f"Validation error: {e}")
Metadata
Release files for telicent-validation-tool 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| telicent_validation_tool-0.2.1.tar.gz | 14.8 kB | With provenance | Details for telicent_validation_tool-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| telicent_validation_tool-0.2.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for telicent_validation_tool-0.2.1-py2.py3-none-any.whl |
Total release size: 27.8 kB
Release files / telicent_validation_tool-0.2.1.tar.gz
| Download URL | telicent_validation_tool-0.2.1.tar.gz |
|---|---|
| Size | 14.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ece938601adab1f91eb9a8520f95822168b1ccde076f58fb5c114484554381b
|
|
BLAKE2b-256 checksum How to use checksums |
b4658443f792d52fe1b60dc35ab330d43b98a74a25c933f21e397b66fdc4a144
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2024.
Transparency logRelease files / telicent_validation_tool-0.2.1-py2.py3-none-any.whl
| Download URL | telicent_validation_tool-0.2.1-py2.py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
715cfa4241f70110d63e4fa0f3c5ef32627c71173a983132bf54fb84487456e9
|
|
BLAKE2b-256 checksum How to use checksums |
c44eb2246bd02a73a8e34147ef8ce8b92a01d8cef84deb0f36f5d6dc74ec2283
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2024.
Transparency logSecurity for telicent-validation-tool 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for telicent_validation_tool-0.2.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2024.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.