Add linkml-validator support
kevinschaper opened this issue · 0 comments
kevinschaper commented
We should add linkml-validator support directly into Koza.
Command line usage should be something like an optional extra argument specifying a schema that will trigger validation
koza transform --source ingest.yaml --schema biolink-model.yaml
or directly as a module with:
transform_source(
source="...",
output_dir="...",
output_format=OutputFormat.tsv,
local_table=None,
global_table=None,
schema="./biolink-model.yaml"
)
Here is the linkml-validator module example
from linkml_validator.validator import Validator
data_obj = {
"id": "obj1",
"name": "Object 1",
"type": "X"
}
validator = Validator(schema="examples/example_schema.yaml")
validator.validate(obj=data_obj, target_class="NamedThing")
We'll likely want to make the schema an argument to set_koza_app and have the validator be defined in the KozaApp init, where a validator can be instantiated.
Then the write method should run validation if a validator exists.