coar-notify-validator
Installation
pip install coar-notify-validator
Usage
validate()
Validate a COAR Notify payload against a schema determined by the payload's type value:
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(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(valid_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"
# }
#
# ]
validate_by_shape_file()
Validate a COAR Notify payload against a specified schema:
from coar_notify_validator.shape_files import ShapefileType
from coar_notify_validator.validate import validate_by_shape_file
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_by_shape_file(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_by_shape_file(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"
# }
#
# ]
Metadata
Release files for coar-notify-validator 0.0.4
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 |
|---|---|---|---|---|
| coar_notify_validator-0.0.4.tar.gz | 8.8 kB | Without provenance | Details for coar_notify_validator-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| coar_notify_validator-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for coar_notify_validator-0.0.4-py3-none-any.whl |
Total release size: 29.0 kB
Release files / coar_notify_validator-0.0.4.tar.gz
| Download URL | coar_notify_validator-0.0.4.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8a5f376c04f7f15836c874248ef7db6ad07d411c691a6bbdbd3f4f702006a732
|
|
BLAKE2b-256 checksum How to use checksums |
5055d9fe06a6936380b770fc43f08f9af5ef826d3c7f89b47c2ae1a0b39378b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / coar_notify_validator-0.0.4-py3-none-any.whl
| Download URL | coar_notify_validator-0.0.4-py3-none-any.whl |
|---|---|
| Size | 20.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f08a951cb77a6cc6efd497a07eacde67dc64b46f1d5615ef5b2104e26e22ecdf
|
|
BLAKE2b-256 checksum How to use checksums |
fa96853ae2d746bb4e0de56f0afaad22842d41af813f8f32164f10f25afa6012
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for coar-notify-validator 0.0.4
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.