Skip to content

Conversation

@mattpodwysocki
Copy link
Contributor

@mattpodwysocki mattpodwysocki commented Jan 8, 2026

Summary

Adds a new offline validation tool that validates Mapbox style JSON against the Mapbox Style Specification. This is the first in a series of offline validation/utility tools.

What's New

validate_style_tool

Purpose: Validate Mapbox style JSON without making API calls

Features:

  • ✅ Comprehensive offline validation (no API access required, no token needed)
  • ✅ Validates required fields (version, sources, layers)
  • ✅ Checks valid layer types and source types
  • ✅ Detects duplicate layer IDs
  • ✅ Validates source references
  • ✅ Identifies missing required properties
  • ✅ Returns structured errors, warnings, and info messages with suggestions
  • ✅ Provides style summary statistics

Input:

{
  style: MapboxStyleJSON | string  // Style object or JSON string
}

Output:

{
  valid: boolean,
  errors: Array<{ severity, message, path, suggestion }>,
  warnings: Array<{ severity, message, path, suggestion }>,
  info: Array<{ severity, message, path, suggestion }>,
  summary: {
    version: number,
    layerCount: number,
    sourceCount: number,
    hasSprite: boolean,
    hasGlyphs: boolean
  }
}

Testing

✅ 11 comprehensive test cases covering:

  • Valid styles
  • Missing required fields
  • Invalid layer types
  • Duplicate layer IDs
  • Non-existent source references
  • JSON string parsing
  • Warnings and info messages
  • Summary statistics

All tests passing.

Documentation

  • ✅ Added to README.md with clear description
  • ✅ Inline code documentation
  • ✅ Schema descriptions for all fields

Architecture

  • Pattern: Extends BaseTool (offline tool, no HttpRequest dependency)
  • Validation: Input/output validated with Zod schemas
  • Location: src/tools/validate-style-tool/

Future Work

This tool is part of a planned suite of offline validation tools:

  • validate_geojson_tool
  • validate_expression_tool
  • compare_styles_tool
  • check_color_contrast_tool
  • optimize_style_tool

Each will be added in separate PRs for easier review.

Why This Matters

Offline validation tools provide:

  • ⚡ Fast feedback (no network latency)
  • 🔒 Privacy (data stays local)
  • 💰 No API costs
  • 🛡️ Catch errors before upload

Perfect for catching common mistakes before calling Mapbox APIs.

Testing

Test 1:

"Can you validate this Mapbox style for me?"

  {
    "version": 8,
    "sources": {},
    "layers": [
      {"id": "bg", "type": "background"}
    ]
  }

Claude will:

  1. Use validate_style_tool
  2. Report validation results
  3. Suggest fixes for any issues
Screenshot 2026-01-09 at 12 09 02

🤖 Generated with Claude Code

- Validates Mapbox style JSON against the Mapbox Style Specification
- Performs comprehensive offline validation (no API calls required)
- Checks required fields, layer types, source types, references
- Detects duplicate IDs, invalid configurations, missing properties
- Returns structured errors, warnings, and info messages
- Includes style summary (version, counts, sprite/glyphs status)
- 11 comprehensive test cases covering all validation scenarios
- Added documentation to README

This is the first of several offline validation tools planned.
@mattpodwysocki mattpodwysocki merged commit 0474af2 into main Jan 9, 2026
1 check passed
@mattpodwysocki mattpodwysocki deleted the add-validate-style-tool branch January 9, 2026 23:11
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.

2 participants