Utility for validating COAR Notify payloads.
Project description
coar-notify-validator
Installation
pip install coar-notify-validator
Usage
Validate a COAR Notify payload against the schema
from coar_notify_validator.shape_files import ShapefileType
from coar_notify_validator.validate import validate
valid_payload = {
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://purl.org/coar/notify"
],
"actor": {
"id": "https://review-service.org/",
"name": "Review Service",
"type": "Service"
},
"context": {
"id": "https://doi.org/10.1101/2022.10.06.511170"
},
"id": "urn:uuid:572b8e81-d92f-4ed5-8178-cc7f04f44cd1",
"object": {
"id": "https://review-service.org/reviews/1223155",
"ietf:cite-as": "10.5072/zenodo.1223155",
"type": [
"Document",
"sorg:Review"
]
},
"origin": {
"id": "https://review-service.org/",
"inbox": "https://review-service.org/inbox",
"type": "Service"
},
"target": {
"id": "https://preprint-repository.org/",
"inbox": "https://preprint-repository.org/inbox",
"type": "Service"
},
"type": [
"Announce",
"coar-notify:ReviewAction"
],
"updated": "2022-10-06T15:00:00.000000"
}
conforms, errors = validate(ShapefileType.ANNOUNCE_REVIEW, valid_payload)
print(conforms) # True
print(errors) # []
invalid_payload = {
"@context": [
"https://www.w3.org/ns/activitystreams",
"https://purl.org/coar/notify"
],
"actor": {
"id": "https://review-service.org/",
"name": "Review Service",
"type": "Service"
},
"context": {
"id": "https://doi.org/10.1101/2022.10.06.511170"
},
"id": "urn:uuid:572b8e81-d92f-4ed5-8178-cc7f04f44cd1",
"object": {
"id": "https://review-service.org/reviews/1223155",
"ietf:cite-as": "10.5072/zenodo.1223155",
"type": [
"Document",
"sorg:Review"
]
},
"origin": {
"id": "https://review-service.org/",
"inbox": "https://review-service.org/inbox",
"type": "Service"
},
"target": {
"id": "https://preprint-repository.org/",
# Missing inbox - should be required
"type": "Service"
},
"type": [
"Announce",
"coar-notify:ReviewAction"
],
"updated": "2022-10-06T15:00:00.000000"
}
conforms, errors = validate(ShapefileType.ANNOUNCE_REVIEW, invalid_payload)
print(conforms) # False
print(errors)
# [
# {
# "focus_node": "<https://preprint-repository.org/",
# "message": "Less than 1 values on <https://preprint-repository.org/-ldp:inbox",
# "result_path": "ldp:inbox",
# "severity": "sh:Violation",
# "source_shape": "ex:InboxShape"
# }
#
# ]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for coar_notify_validator-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffb27695759945bb8136d5677f1e2c83e1752e50e6d79c4b5e84d63e4fe33874 |
|
MD5 | 0568239a215e6b693ce9f2f42b29ed47 |
|
BLAKE2b-256 | 9510e59c01b2e4f683d560fa0368a16274e6fd464d979030bcca9e1f7cec8fd6 |
Close
Hashes for coar_notify_validator-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bea0b8e5effbd9ba390dd09a4b95519033da46560998fd700822799fdc4de436 |
|
MD5 | d4d090882b099cf164e9fcb95543e5a6 |
|
BLAKE2b-256 | 6053d59b8291e7ee3a72f44d242ae100288519bcc5e685f3333634d3013d65ea |