Skip to content

Plugin Reference

linkml-term-validator provides LinkML ValidationPlugin implementations plus a standalone schema validator. Import plugins from linkml_term_validator.plugins unless you need an internal module directly.

Shared Options

The ontology-backed plugins share these constructor options:

Parameter Default Description
oak_adapter_string sqlite:obo: Default OAK adapter string
cache_labels True Write ontology labels to the file cache
cache_dir cache Directory for label and enum caches
oak_config_path None Path to oak_config.yaml
offline False Read only from cache; never build OAK adapters

Dynamic enum capable plugins also accept:

Parameter Default Description
cache_enum_expansions True Write dynamic enum expansion caches
saturate_enum_caches False Materialize full closures during progressive validation
cache_strategy progressive progressive or greedy

PermissibleValueMeaningPlugin

Validates schema enum permissible value meaning fields. It checks that each CURIE resolves and that the ontology label matches one of the schema-provided labels.

from linkml_term_validator.plugins import PermissibleValueMeaningPlugin

plugin = PermissibleValueMeaningPlugin(
    oak_adapter_string="sqlite:obo:",
    oak_config_path="oak_config.yaml",
    strict_mode=False,
    cache_labels=True,
    cache_dir="cache",
    offline=False,
)

Additional option:

Parameter Default Description
strict_mode False Treat warnings as errors

For direct schema validation outside LinkML's plugin lifecycle, use EnumValidator:

from linkml_term_validator.models import ValidationConfig
from linkml_term_validator.validator import EnumValidator

config = ValidationConfig(
    oak_config_path="oak_config.yaml",
    cache_dir="cache",
)
validator = EnumValidator(config)
result = validator.validate_schema("schema.yaml")

if result.has_errors():
    for issue in result.issues:
        print(f"{issue.severity}: {issue.message}")

DynamicEnumPlugin

Validates data values whose slot range is a dynamic enum.

from linkml.validator import Validator
from linkml.validator.loaders import YamlLoader
from linkml_term_validator.plugins import DynamicEnumPlugin

plugin = DynamicEnumPlugin(
    oak_adapter_string="sqlite:obo:",
    oak_config_path="oak_config.yaml",
    cache_strategy="progressive",
)

validator = Validator(schema="schema.yaml", validation_plugins=[plugin])
loader = YamlLoader("data.yaml")
report = validator.validate_source(loader, target_class="Sample")

It validates:

  • reachable_from: descendants by default, or ancestors when traverse_up: true
  • include_self: source nodes are excluded by default and included only when true
  • concepts: explicit concept lists
  • include, minus, and inherits: enum expression composition
  • static permissible_values: both permissible value names and meaning CURIEs

matches expressions are recognized as dynamic enum definitions and included in cache keys, but full pattern-match validation is not implemented yet.

BindingValidationPlugin

Validates LinkML bindings on nested objects and, by default, validates labels on the same nested object.

from linkml.validator import Validator
from linkml.validator.loaders import YamlLoader
from linkml_term_validator.plugins import BindingValidationPlugin

plugin = BindingValidationPlugin(
    oak_adapter_string="sqlite:obo:",
    oak_config_path="oak_config.yaml",
    validate_labels=True,
    strict=True,
)

validator = Validator(schema="schema.yaml", validation_plugins=[plugin])
loader = YamlLoader("data.yaml")
report = validator.validate_source(loader, target_class="GeneAnnotation")

Additional options:

Parameter Default Description
validate_labels True Check nested label fields against ontology labels
strict True Fail when configured term IDs cannot be resolved

The plugin:

  • Recursively walks nested objects, including multivalued nested objects
  • Applies binds_value_of to extract the field constrained by the binding
  • Validates static and dynamic enum ranges
  • Uses slots with implements: [rdfs:label] or slot_uri: rdfs:label as label fields
  • Falls back to a field named label when no label property is declared

Composition

Use both data plugins when a schema has direct dynamic enum slots and nested binding objects:

from linkml.validator import Validator
from linkml.validator.loaders import YamlLoader
from linkml_term_validator.plugins import DynamicEnumPlugin, BindingValidationPlugin

plugins = [
    DynamicEnumPlugin(oak_config_path="oak_config.yaml"),
    BindingValidationPlugin(oak_config_path="oak_config.yaml"),
]

validator = Validator(schema="schema.yaml", validation_plugins=plugins)
report = validator.validate_source(YamlLoader("data.yaml"), target_class="Sample")

The CLI validate-data command creates this composition by default. Disable either part with --no-dynamic-enums or --no-bindings.

linkml-validate Configuration

All plugins can be configured for linkml-validate:

schema: schema.yaml
target_class: Sample
data_sources:
  - data.yaml

plugins:
  "linkml_term_validator.plugins.DynamicEnumPlugin":
    oak_adapter_string: "sqlite:obo:"
    oak_config_path: oak_config.yaml
    cache_dir: cache
    cache_strategy: progressive

  "linkml_term_validator.plugins.BindingValidationPlugin":
    oak_adapter_string: "sqlite:obo:"
    oak_config_path: oak_config.yaml
    validate_labels: true
    cache_dir: cache
    cache_strategy: progressive
linkml-validate --config validation_config.yaml

See Also