Add JSON Schema validation for front matter with taxonomy enum validation #991
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Details
Description
Implements automatic validation of YAML front matter against content type definitions using JSON Schema. When a markdown file is opened, its front matter is validated in real-time and errors are surfaced as inline warnings.
Implementation
ContentTypeSchemaGenerator - Converts content type field definitions to JSON Schema
FrontMatterValidator - Validates front matter using AJV
StatusListener integration - Adds schema validation to existing diagnostics
---delimiters)missingPropertyparameterExample
Given a content type:
Invalid front matter triggers inline warnings:
Taxonomy Validation
The validation now checks tags, categories, and custom taxonomy fields against known values:
TaxonomyHelper.get(TaxonomyType.Tag)TaxonomyHelper.get(TaxonomyType.Category)This helps catch typos early, enforces consistency, and ensures only valid taxonomy values are used across content.
Known Limitations
Field location detection uses string matching (
fieldName:) within front matter section. More precise location reporting would require YAML AST parsing.Related Issue
Fixes enhancement request for schema validation of front matter.
Motivation and Context
Content type definitions specify structure but weren't enforced at edit-time. This creates a tight feedback loop by validating as users type, catching errors before they cause issues downstream. The addition of taxonomy validation prevents inconsistent tag/category usage and catches typos immediately.
How Has This Been Tested
Types of changes
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.