Skip to content

feat: refactor Bom.validate() to ModelValidator...#935

Draft
saquibsaifee wants to merge 4 commits intoCycloneDX:mainfrom
saquibsaifee:feat/refactor-validation-to-model-validator
Draft

feat: refactor Bom.validate() to ModelValidator...#935
saquibsaifee wants to merge 4 commits intoCycloneDX:mainfrom
saquibsaifee:feat/refactor-validation-to-model-validator

Conversation

@saquibsaifee
Copy link
Copy Markdown
Contributor

Description

Refactors the validation logic from Bom.validate() to a new ModelValidator class in cyclonedx.validation.model, providing a more extensible validation framework.

Changes

  • Implement ModelValidator in cyclonedx.validation.model
  • ModelValidator.validate() returns Iterable[ModelValidationError] for advanced error reporting
  • ModelValidator is side-effect free (no object mutation)
  • Deprecate Bom.validate() with backward compatibility
  • Bom.validate() maintains side-effects (dependency registration) for compatibility
  • Add comprehensive tests for ModelValidator

Backward Compatibility

The deprecated Bom.validate() method:

  • Continues to work exactly as before
  • Maintains side-effects (calls register_dependency)
  • Raises the first error encountered (existing behavior)
  • Emits DeprecationWarning pointing to ModelValidator

Resolves or fixes issue: #455

AI Tool Disclosure

  • My contribution does not include any AI-generated content
  • My contribution includes AI-generated content, as disclosed below:
    • AI Tools: Antigravity
    • LLMs and versions: Gemini 3 Fast

Affirmation

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community Bot commented Feb 15, 2026

Documentation build overview

📚 CycloneDX Python Library | 🛠️ Build #32417460 | 📁 Comparing d726148 against latest (4ef5bc3)

  🔍 Preview build  

3 files changed
± genindex.html
± autoapi/cyclonedx/model/bom/index.html
± autoapi/cyclonedx/validation/model/index.html

Signed-off-by: Saquib Saifee <saquibsaifee2@gmail.com>
@saquibsaifee saquibsaifee force-pushed the feat/refactor-validation-to-model-validator branch from 228bc94 to 745d773 Compare February 15, 2026 04:44
@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 2 complexity · 0 duplication

Metric Results
Complexity 2
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

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.

1 participant