Skip to content

Conversation

@domdomegg
Copy link
Contributor

Summary

Implements detection of JSON Schema string validation constraints: pattern, minLength, and maxLength.

Changes

Pattern Support

  • PatternAdd/Remove/Change change types
  • Pattern changes conservatively treated as breaking (determining if one regex is a subset of another requires complex AST analysis or fuzzing, which is out of scope per issue discussion)

MinLength Support

  • MinLengthAdd/Remove/Change change types
  • Smart breaking logic:
    • Increasing minLength: breaking (rejects previously valid shorter strings)
    • Decreasing minLength: non-breaking (accepts more strings)

MaxLength Support

  • MaxLengthAdd/Remove/Change change types
  • Smart breaking logic:
    • Decreasing maxLength: breaking (rejects previously valid longer strings)
    • Increasing maxLength: non-breaking (accepts more strings)

Test Coverage

14 comprehensive test fixtures covering:

  • Pattern: add, remove, change, unchanged
  • MinLength: add, remove, increase (breaking), decrease (non-breaking), unchanged
  • MaxLength: add, remove, decrease (breaking), increase (non-breaking), unchanged

Examples

# Pattern add (breaking)
{"path":"","change":{"PatternAdd":{"added":"^[a-z]+$"}},"is_breaking":true}

# MinLength increase 3→5 (breaking)
{"path":"","change":{"MinLengthChange":{"old_value":3,"new_value":5}},"is_breaking":true}

# MinLength decrease 5→3 (non-breaking)
{"path":"","change":{"MinLengthChange":{"old_value":5,"new_value":3}},"is_breaking":false}

# MaxLength decrease 10→5 (breaking)
{"path":"","change":{"MaxLengthChange":{"old_value":10,"new_value":5}},"is_breaking":true}

Fixes #23
Fixes #50

Implements detection of JSON Schema string validation constraints.

Changes:
- Add 9 new change types for pattern, minLength, and maxLength
- Pattern changes conservatively treated as breaking (regex subset
  detection is complex and out of scope)
- MinLength/MaxLength with smart directional breaking logic:
  - Increasing minLength: breaking (rejects shorter strings)
  - Decreasing minLength: non-breaking (accepts more strings)
  - Decreasing maxLength: breaking (rejects longer strings)
  - Increasing maxLength: non-breaking (accepts more strings)
- Comprehensive test coverage: 14 test fixtures covering all scenarios

Fixes getsentry#23
Fixes getsentry#50

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@domdomegg domdomegg requested a review from a team as a code owner October 7, 2025 13:58
@github-actions
Copy link

github-actions bot commented Jan 29, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (release) Replace release bot with GH app by Jeffreyhung in #41
  • Add string validation support (pattern, minLength, maxLength) by domdomegg in #51
  • Support format by brhutchins in #45
  • Support custom ids and $defs from draft 2020-12 by cakemanny in #44

Internal Changes 🔧

Release

  • Fix changelog-preview permissions by BYK in #54
  • Switch from action-prepare-release to Craft by BYK in #52

Other

  • Use pull_request_target for changelog preview by BYK in #53

Other

  • Fix clippy lints by untitaker in #42

🤖 This preview updates automatically when you update the PR.

@untitaker untitaker merged commit 8078870 into getsentry:main Jan 29, 2026
5 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.

String validation support Support for pattern and format

2 participants