-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validation endpoint? #156
Comments
We don't have a fixed return format for this yet, right? I think it would be good to know not only if the object is valid JSKOS, but also whether it can be important (and the reason if it can't). For an array of objects, it would also be good to have that result for each of the objects. |
We can just pass errors of jskos-validate. This should do: const validate = require("jskos-validate")
const { guessObjectType } = require("jskos-tools")
// additional parameters (optional)
const unknownFields = params.ignoreUnknownFields
const type = (guessObjectType(params.type, true) || "").toLowerCase()
const rememberSchemes = type ? [] : null
const validator = type ? validate[type] : validate
const result = input.map(data => {
const result = validator(data, { unknownFields, rememberSchemes })
return result ? true : validator.errors
}) |
To include information about concept schemes stored in jskos-server, the
Are there other checks when importing data, e.g. detection of circular |
So, the first implementation is in Dev.
I still don't fully understand how
No detection of circular narrower links or anything like that. Duplicate URIs/identifiers are also not detected directly, but trying to POST an existing object will return an error, except when bulk importing. I'm also unsure why this would be relevant for this issue. I thought we just want to check whether a JSKOS object is valid or not. |
I've updated the code and it works like expected. For instance: [
{
"type": ["http://www.w3.org/2004/02/skos/core#ConceptScheme"],
"uri": "http://example.org/voc",
"notationPattern": "[a-z]+"
},
{
"type": ["http://www.w3.org/2004/02/skos/core#Concept"],
"uri": "http://example.org/1",
"notation": ["abc"],
"inScheme": [{"uri": "http://example.org/voc"}]
},
{
"type": ["http://www.w3.org/2004/02/skos/core#Concept"],
"uri": "http://example.org/2",
"notation": ["123"],
"inScheme": [{"uri": "http://example.org/voc"}]
}
] results in [
true,
true,
[
{
"message": "concept notation 123 does not match [a-z]+"
}
]
] With question: should we better return
validation endpoint could be used as dry-run before import so additional integrity constraints of import should optionally be enforced on validation as well. But this is not the case and if so, another issue. |
That's a good point. I'm a bit split on this issue because on the one hand, I agree that it would make things slightly easier to check, but on the other hand,
Yeah, I'm still not sure whether that makes sense, so please make a separate issue that's of lower priority. I guess I'll now finish the rest of the tasks, in particular tests and documentation. |
There might be issues with JSON parsing when only a boolean value is returned. This will be reflected in the documentation.
I added the documentation with same example calls. @nichtich Could you please check the documentation to make sure there were no misunderstandings? I tried to explain how things like I will add tests after you checked it because it might change things. |
Ok, I've completed the documentation. What's also missing is inclusion of validation endpoint at |
I will add some more tests tomorrow, in particular those that use the parameters, but after that I think this is finished. 👍 |
Maybe jskos-server might be the right place for gbv/jskos#105:
Add
POST /validate
andGET /validate?url=
where you can send a JSKOS document (single object or array of objects) to be validated. Optional parameterValidation could either be agnostic to the current database content (just use jskos-validate library >=0.5.1 with option
rememberSchemes
unless specific type is specified) or it could be a dry run of import script. The latter would also check whether concepts and/or mappings match to an existing vocabulary in the database.The text was updated successfully, but these errors were encountered: