Skip to content

Add DynamicTable compatibility validators#825

Merged
ehennestad merged 4 commits into
mainfrom
add-dynamic-table-compatibility-validators
Jun 2, 2026
Merged

Add DynamicTable compatibility validators#825
ehennestad merged 4 commits into
mainfrom
add-dynamic-table-compatibility-validators

Conversation

@ehennestad
Copy link
Copy Markdown
Collaborator

@ehennestad ehennestad commented May 31, 2026

Motivation

Adds reusable argument-validation functions for DynamicTable and VectorData that accept the type across compatible namespaces — types.hdmf_common and the legacy types.core. The error message is specific to the currently generated NWB schema version, to avoid confusion about hdmf_common vs core namespace.

Example of current validation:

types.util.dynamictable.nwbToTable(table())

Error message:

Error using types.util.dynamictable.nwbToTable
Expected input to be one of these types:

types.core.DynamicTable, types.hdmf_common.DynamicTable

Instead its type was table.

This message is not specific to which NWB schema is currently generated/active. Unless someone is working with legacy schema versions, the types.core.DynamicTable expectation is misleading.

Example with updated validation function:

For current schema version:

generateCore()
matnwb.common.validation.mustBeDynamicTable(table())

Error message:

Error using matnwb.common.validation.mustBeDynamicTable
Value must be of type types.hdmf_common.DynamicTable but was of type table.

For older schema version:

nwbClearGenerated()
clear all
generateCore('2.1.0')
matnwb.common.validation.mustBeDynamicTable(table())

Error message:

Error using matnwb.common.validation.mustBeDynamicTable
Value must be of type types.core.DynamicTable but was of type table.

What changed

  • matnwb.common.validation.internal.mustBeCompatibleType (new) — validates a value against a neurodata type name across both compatible namespaces (core/hdmf_common).
  • matnwb.common.validation.mustBeDynamicTable / mustBeVectorData — now delegate to the shared helper.

How to test the behavior?

runtests("tests.unit.common.ValidatorTest")

Checklist

  • Have you ensured the PR description clearly describes the problem and solutions?
  • Have you checked to ensure that there aren't other open or previously closed Pull Requests for the same change?
  • If this PR fixes an issue, is the first line of the PR description fix #XX where XX is the issue number?

@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.37%. Comparing base (d122320) to head (814df61).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #825      +/-   ##
==========================================
+ Coverage   95.36%   95.37%   +0.01%     
==========================================
  Files         214      215       +1     
  Lines        7550     7569      +19     
==========================================
+ Hits         7200     7219      +19     
  Misses        350      350              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds reusable MATLAB argument-validation helpers to treat legacy types.core and current types.hdmf_common classes as compatible, enabling arguments-block validation for DynamicTable utilities across schema versions.

Changes:

  • Introduces matnwb.common.validation.internal.mustBeCompatibleType to validate a neurodata type name across both types.hdmf_common and legacy types.core.
  • Refactors mustBeDynamicTable and mustBeVectorData to delegate validation to the shared helper.
  • Improves the validator error message specificity by reporting the expected fully-qualified type name that exists on the MATLAB path.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
+matnwb/+common/+validation/mustBeVectorData.m Delegates VectorData validation to the new compatibility helper.
+matnwb/+common/+validation/mustBeDynamicTable.m Delegates DynamicTable validation to the new compatibility helper.
+matnwb/+common/+validation/+internal/mustBeCompatibleType.m Adds shared validator that accepts compatible generated types across namespaces and differentiates “wrong type” vs “types missing from path”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread +matnwb/+common/+validation/+internal/mustBeCompatibleType.m Outdated
Comment thread +matnwb/+common/+validation/mustBeDynamicTable.m
Comment thread +matnwb/+common/+validation/mustBeVectorData.m
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ehennestad ehennestad enabled auto-merge June 1, 2026 12:57
@ehennestad ehennestad requested a review from bendichter June 2, 2026 09:00
@ehennestad ehennestad added this pull request to the merge queue Jun 2, 2026
Merged via the queue into main with commit 129f7ce Jun 2, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants