Repository navigation
refactor(format): move format validation out of JsonValidator into Formats - #101
Merged
Merged
Conversation
…rmats Move the `format` dispatch and the remaining format families into a new `internal object Formats` (Formats.kt) with the entry point `Formats.isValid(format, value)`: date, time and date-time; email with its local-part and domain helpers, and idn-email; json-pointer, relative-json-pointer and uuid; uri-template and its helpers; duration; and the regex and character-set constants only they use. The `when` keeps its branches in the same order, and unknown formats are still valid. IDNA, the ECMA 262 regex dialect and the URI grammar stay in Idna, EcmaRegex and UriSyntax, called from Formats. JsonValidator keeps `formatAssertion` and the error: `validateFormat()` now only reports a failed `Formats.isValid()` with the same message and keyword location. Why: the formats are their own vocabulary in the 2020-12 spec (DDD), and their grammars change with their RFCs, not with keyword evaluation (SRP). There is no FormatValidator interface or registry (YAGNI): one implementation, no request for custom formats, and the `when` stays compiler-checked. Behaviour is unchanged: function bodies, comments and constants moved verbatim (REGEX_UUID re-indented), and the full suite passes. Closes #96 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Owner
Author
Review of #101: format validation moved into
|
List the format families that live in Formats.kt in CLAUDE.md's Format Validation section, fix the stale validateFormat KDoc, and drop the unused SchemaKeywords.SCHEMA import from JsonValidator. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Moves format validation out of
JsonValidator.ktinto a newinternal object FormatsinFormats.kt, as proposed in #96. This is a pure move with no behaviour change.Formats.isValid(format, value)holds thewhendispatch fromvalidateFormat. Its 20 branches are in the same order, and unknown formats still return true.REGEX_UUIDis re-indented)JsonValidatorkeepsformatAssertionand the error.validateFormat()is still a function and now only reports a failedFormats.isValid(), with the same message andformatkeyword location.Idna,EcmaRegexandUriSyntaxare unchanged, now made fromFormats.SchemaKeywords.FORMAT_*imports are removed fromJsonValidator.JsonValidator.ktgoes from 2,031 to 1,701 lines.Formats.ktis 340 lines.memory/MEMORY.md. There is no CHANGELOG entry because this is an internal refactor.There is no interface or registry, per the issue (YAGNI).
Verification
./gradlew ktlintFormat, thenCI=true ./gradlew test ktlintCheck --rerun-tasks, including the official suite: 5,849 tests, 0 failures, 0 errors, 0 skipped, read frombuild/test-results/test/*.xml.test_counts.pyexits 0 and reports a full run of 5,849.origin/masterafter normalising indentation and visibility. All 15 functions, the 12 constants with their comments, and the 20whenbranches in order are identical.Closes #96
🤖 Generated with Claude Code