# coar-notify-validator
### Installation
```bash
pip install coar-notify-validator
```
### Usage
## validate()
#### Validate a COAR Notify payload against a schema determined by the payload's `type` value:
```python
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:
```python
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"
# }
#
# ]
```
Raw data
{
"_id": null,
"home_page": "https://github.com/seanwiseman/coar-notify-validator.git",
"name": "coar-notify-validator",
"maintainer": "Sean Wiseman",
"docs_url": null,
"requires_python": "",
"maintainer_email": "seanwiseman2012@gmail.com",
"keywords": "",
"author": "",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/50/55/d9fe06a6936380b770fc43f08f9af5ef826d3c7f89b47c2ae1a0b39378b3/coar_notify_validator-0.0.4.tar.gz",
"platform": null,
"description": "# coar-notify-validator\n\n\n### Installation\n\n```bash\npip install coar-notify-validator\n```\n\n\n### Usage\n\n## validate()\n#### Validate a COAR Notify payload against a schema determined by the payload's `type` value:\n```python\nfrom coar_notify_validator.validate import validate\n\nvalid_payload = {\n \"@context\": [\n \"https://www.w3.org/ns/activitystreams\",\n \"https://purl.org/coar/notify\"\n ],\n \"actor\": {\n \"id\": \"https://review-service.org/\",\n \"name\": \"Review Service\",\n \"type\": \"Service\"\n },\n \"context\": {\n \"id\": \"https://doi.org/10.1101/2022.10.06.511170\"\n },\n \"id\": \"urn:uuid:572b8e81-d92f-4ed5-8178-cc7f04f44cd1\",\n \"object\": {\n \"id\": \"https://review-service.org/reviews/1223155\",\n \"ietf:cite-as\": \"10.5072/zenodo.1223155\",\n \"type\": [\n \"Document\",\n \"sorg:Review\"\n ]\n },\n \"origin\": {\n \"id\": \"https://review-service.org/\",\n \"inbox\": \"https://review-service.org/inbox\",\n \"type\": \"Service\"\n },\n \"target\": {\n \"id\": \"https://preprint-repository.org/\",\n \"inbox\": \"https://preprint-repository.org/inbox\",\n \"type\": \"Service\"\n },\n \"type\": [\n \"Announce\",\n \"coar-notify:ReviewAction\"\n ],\n \"updated\": \"2022-10-06T15:00:00.000000\"\n}\n\nconforms, errors = validate(valid_payload)\n\nprint(conforms) # True\nprint(errors) # []\n\ninvalid_payload = {\n \"@context\": [\n \"https://www.w3.org/ns/activitystreams\",\n \"https://purl.org/coar/notify\"\n ],\n \"actor\": {\n \"id\": \"https://review-service.org/\",\n \"name\": \"Review Service\",\n \"type\": \"Service\"\n },\n \"context\": {\n \"id\": \"https://doi.org/10.1101/2022.10.06.511170\"\n },\n \"id\": \"urn:uuid:572b8e81-d92f-4ed5-8178-cc7f04f44cd1\",\n \"object\": {\n \"id\": \"https://review-service.org/reviews/1223155\",\n \"ietf:cite-as\": \"10.5072/zenodo.1223155\",\n \"type\": [\n \"Document\",\n \"sorg:Review\"\n ]\n },\n \"origin\": {\n \"id\": \"https://review-service.org/\",\n \"inbox\": \"https://review-service.org/inbox\",\n \"type\": \"Service\"\n },\n \"target\": {\n \"id\": \"https://preprint-repository.org/\",\n # Missing inbox - should be required\n \"type\": \"Service\"\n },\n \"type\": [\n \"Announce\",\n \"coar-notify:ReviewAction\"\n ],\n \"updated\": \"2022-10-06T15:00:00.000000\"\n}\n\nconforms, errors = validate(valid_payload)\nprint(conforms) # False\nprint(errors)\n# [\n# {\n# \"focus_node\": \"<https://preprint-repository.org/\",\n# \"message\": \"Less than 1 values on <https://preprint-repository.org/-ldp:inbox\",\n# \"result_path\": \"ldp:inbox\",\n# \"severity\": \"sh:Violation\",\n# \"source_shape\": \"ex:InboxShape\"\n# }\n# \n# ]\n\n\n```\n\n## validate_by_shape_file()\n#### Validate a COAR Notify payload against a specified schema:\n```python\nfrom coar_notify_validator.shape_files import ShapefileType\nfrom coar_notify_validator.validate import validate_by_shape_file\n\nvalid_payload = {\n \"@context\": [\n \"https://www.w3.org/ns/activitystreams\",\n \"https://purl.org/coar/notify\"\n ],\n \"actor\": {\n \"id\": \"https://review-service.org/\",\n \"name\": \"Review Service\",\n \"type\": \"Service\"\n },\n \"context\": {\n \"id\": \"https://doi.org/10.1101/2022.10.06.511170\"\n },\n \"id\": \"urn:uuid:572b8e81-d92f-4ed5-8178-cc7f04f44cd1\",\n \"object\": {\n \"id\": \"https://review-service.org/reviews/1223155\",\n \"ietf:cite-as\": \"10.5072/zenodo.1223155\",\n \"type\": [\n \"Document\",\n \"sorg:Review\"\n ]\n },\n \"origin\": {\n \"id\": \"https://review-service.org/\",\n \"inbox\": \"https://review-service.org/inbox\",\n \"type\": \"Service\"\n },\n \"target\": {\n \"id\": \"https://preprint-repository.org/\",\n \"inbox\": \"https://preprint-repository.org/inbox\",\n \"type\": \"Service\"\n },\n \"type\": [\n \"Announce\",\n \"coar-notify:ReviewAction\"\n ],\n \"updated\": \"2022-10-06T15:00:00.000000\"\n}\n\nconforms, errors = validate_by_shape_file(ShapefileType.ANNOUNCE_REVIEW, valid_payload)\n\nprint(conforms) # True\nprint(errors) # []\n\ninvalid_payload = {\n \"@context\": [\n \"https://www.w3.org/ns/activitystreams\",\n \"https://purl.org/coar/notify\"\n ],\n \"actor\": {\n \"id\": \"https://review-service.org/\",\n \"name\": \"Review Service\",\n \"type\": \"Service\"\n },\n \"context\": {\n \"id\": \"https://doi.org/10.1101/2022.10.06.511170\"\n },\n \"id\": \"urn:uuid:572b8e81-d92f-4ed5-8178-cc7f04f44cd1\",\n \"object\": {\n \"id\": \"https://review-service.org/reviews/1223155\",\n \"ietf:cite-as\": \"10.5072/zenodo.1223155\",\n \"type\": [\n \"Document\",\n \"sorg:Review\"\n ]\n },\n \"origin\": {\n \"id\": \"https://review-service.org/\",\n \"inbox\": \"https://review-service.org/inbox\",\n \"type\": \"Service\"\n },\n \"target\": {\n \"id\": \"https://preprint-repository.org/\",\n # Missing inbox - should be required\n \"type\": \"Service\"\n },\n \"type\": [\n \"Announce\",\n \"coar-notify:ReviewAction\"\n ],\n \"updated\": \"2022-10-06T15:00:00.000000\"\n}\n\nconforms, errors = validate_by_shape_file(ShapefileType.ANNOUNCE_REVIEW, invalid_payload)\nprint(conforms) # False\nprint(errors)\n# [\n# {\n# \"focus_node\": \"<https://preprint-repository.org/\",\n# \"message\": \"Less than 1 values on <https://preprint-repository.org/-ldp:inbox\",\n# \"result_path\": \"ldp:inbox\",\n# \"severity\": \"sh:Violation\",\n# \"source_shape\": \"ex:InboxShape\"\n# }\n# \n# ]\n\n\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Utility for validating COAR Notify payloads.",
"version": "0.0.4",
"project_urls": {
"Homepage": "https://github.com/seanwiseman/coar-notify-validator.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fa96853ae2d746bb4e0de56f0afaad22842d41af813f8f32164f10f25afa6012",
"md5": "66959555569ad97bc5ae57672edb7245",
"sha256": "f08a951cb77a6cc6efd497a07eacde67dc64b46f1d5615ef5b2104e26e22ecdf"
},
"downloads": -1,
"filename": "coar_notify_validator-0.0.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "66959555569ad97bc5ae57672edb7245",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 20135,
"upload_time": "2023-08-01T14:03:53",
"upload_time_iso_8601": "2023-08-01T14:03:53.346014Z",
"url": "https://files.pythonhosted.org/packages/fa/96/853ae2d746bb4e0de56f0afaad22842d41af813f8f32164f10f25afa6012/coar_notify_validator-0.0.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5055d9fe06a6936380b770fc43f08f9af5ef826d3c7f89b47c2ae1a0b39378b3",
"md5": "8c10fcfd849847dc9efe1b8f76ca533c",
"sha256": "8a5f376c04f7f15836c874248ef7db6ad07d411c691a6bbdbd3f4f702006a732"
},
"downloads": -1,
"filename": "coar_notify_validator-0.0.4.tar.gz",
"has_sig": false,
"md5_digest": "8c10fcfd849847dc9efe1b8f76ca533c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8829,
"upload_time": "2023-08-01T14:03:54",
"upload_time_iso_8601": "2023-08-01T14:03:54.803967Z",
"url": "https://files.pythonhosted.org/packages/50/55/d9fe06a6936380b770fc43f08f9af5ef826d3c7f89b47c2ae1a0b39378b3/coar_notify_validator-0.0.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-01 14:03:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "seanwiseman",
"github_project": "coar-notify-validator",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "kglab",
"specs": [
[
"==",
"0.6.6"
]
]
},
{
"name": "rdflib",
"specs": [
[
"==",
"6.3.2"
]
]
},
{
"name": "pyshacl",
"specs": [
[
"==",
"0.23.0"
]
]
}
],
"lcname": "coar-notify-validator"
}