Skip to content

Commit 8465b44

Browse files
committed
Removed duplicate script and updated readme
1 parent e44ef0e commit 8465b44

File tree

2 files changed

+43
-61
lines changed

2 files changed

+43
-61
lines changed

README.md

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ nodemon src/server
9292
```
9393

9494
## Validation API
95-
This validator exposes two endpoints that will accept POST requests: `/validate` and `/prototype`.
95+
This validator exposes two endpoints that will accept POST requests: `/validate` for a single stand-alone schema and data object, and `/validateRefs` for a complex schema referencing other schemas and a related data object.
9696

9797
### /validate
9898
The endpoint will expect the body to have the following structure:
@@ -139,7 +139,7 @@ Where the schema should be a valid json schema to validate the object against.
139139
}
140140
```
141141

142-
### /prototype
142+
### /validateRefs
143143
The endpoint will expect the body to have the following structure:
144144
```js
145145
{
@@ -247,10 +247,49 @@ Sending malformed JSON or a body with either the schema or the submittable missi
247247

248248
## Custom keywords
249249
The AJV library supports the implementation of custom json schema keywords to address validation scenarios that go beyond what json schema can handle.
250-
This validator has two custom keywords implemented, `isChildTermOf` and `isValidTerm`.
250+
This validator has three custom keywords implemented, `graph_restriction`, `isChildTermOf` and `isValidTerm`.
251+
252+
### graph_restriction
253+
254+
This custom keyword *evaluates if an ontology term is child of another*. This keyword is applied to a string (CURIE) and **passes validation if the term is a child of the term defined in the schema**.
255+
The keyword requires one or more **parent terms** *(classes)* and **ontology ids** *(ontologies)*, both of which should exist in [OLS - Ontology Lookup Service](https://www.ebi.ac.uk/ols).
256+
257+
This keyword works by doing an asynchronous call to the [OLS API](https://www.ebi.ac.uk/ols/api/) that will respond with the required information to know if a given term is child of another.
258+
Being an async validation step, whenever used is a schema, the schema must have the flag: `"$async": true` in it's object root.
259+
260+
261+
#### Usage
262+
Schema:
263+
```js
264+
{
265+
"$schema": "http://json-schema.org/draft-07/schema#",
266+
"$id": "http://schema.dev.data.humancellatlas.org/module/ontology/5.3.0/organ_ontology",
267+
"$async": true,
268+
"properties": {
269+
"ontology": {
270+
"description": "A term from the ontology [UBERON](https://www.ebi.ac.uk/ols/ontologies/uberon) for an organ or a cellular bodily fluid such as blood or lymph.",
271+
"type": "string",
272+
"graph_restriction": {
273+
"ontologies" : ["obo:hcao", "obo:uberon"],
274+
"classes": ["UBERON:0000062","UBERON:0000179"],
275+
"relations": ["rdfs:subClassOf"],
276+
"direct": false,
277+
"include_self": false
278+
}
279+
}
280+
}
281+
}
282+
```
283+
JSON object:
284+
```js
285+
{
286+
"ontology": "UBERON:0000955"
287+
}
288+
```
289+
251290

252291
### isChildTermOf
253-
This custom keyword *evaluates if an ontology term is child of other*. This keyword is applied to a string (url) and **passes validation if the term is a child of the term defined in the schema**.
292+
This custom keyword also *evaluates if an ontology term is child of another* and is a simplified version of the graph_restriction keyword. This keyword is applied to a string (url) and **passes validation if the term is a child of the term defined in the schema**.
254293
The keyword requires the **parent term** and the **ontology id**, both of which should exist in [OLS - Ontology Lookup Service](https://www.ebi.ac.uk/ols).
255294

256295
This keyword works by doing an asynchronous call to the [OLS API](https://www.ebi.ac.uk/ols/api/) that will respond with the required information to know if a given term is child of another.

src/custom/isvalidterm_original.js

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)