Guide: Errors and Debugging
Issue shape
mdshape returns issues with code, path, line, and position.
Example
Input Markdown
md
# LESSON: Complete example
## 2. SUBTITLE
A long enough subtitle for validation.
## 3. OBJECTIVES
- Goal one
- Goal two
- Goal threeSchema
ts
import { md } from '@markschema/mdshape'
const Schema = md.document({
title: md.heading(1),
subtitle: md.section('2. SUBTITLE').paragraphs([md.string().min(20)]),
objectives: md.section('3. OBJECTIVES').list(md.string()).min(3),
})
const schema = SchemaResult
Success
json
{
"success": true,
"data": {
"title": "LESSON: Complete example",
"subtitle": [
"A long enough subtitle for validation."
],
"objectives": [
"Goal one",
"Goal two",
"Goal three"
]
}
}Error
json
{
"success": false,
"error": {
"issues": [
{
"code": "missing_heading",
"message": "Missing heading with depth 1",
"path": [
"title"
],
"line": 1,
"position": {
"start": {
"line": 1,
"column": 1
}
}
}
]
}
}Right vs Wrong
- Right: inspect
code+pathfirst, then useline/position. - Wrong: rely only on
messageand ignorepathcontext.
Common codes
missing_sectionmissing_paragraphunexpected_paragraphmissing_listblock_order_mismatchinvalid_union_discriminator