Repository navigation
honour date facet bounds in xsd2inst samples - #133
Merged
Merged
Conversation
formatDate compared its random seed, a full dateTime, against the bounds before cutting it down to the facet's type, so for date, time and the g* types every comparison came back as incomparable and the bounds were ignored. Where a reset did fire, it moved the random date by a few hours instead of moving it next to the bound. Cut the seed down to the type and pick its timezone first, then check it against all four facets the way validation does, treating an incomparable result as out of range. If it misses, try the bound itself and then the bound stepped inwards by the smallest unit the type shows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pjfanning
force-pushed
the
sample-date-facets
branch
from
October 5, 2026 18:51
57d935f to
dffaef0
Compare
Assert the expected cvc-*-valid code rather than only that validation failed, and compile the schema once for the class. Co-Authored-By: Claude Opus 5.5 <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.
SampleXmlUtil.formatDateignored min/max facets on every date type exceptdateTime, and didn't respect them properly ondateTimeeither.Why
setBuiltinTypeCodecut it down to the facet's type. Fordate,time,gYear,gYearMonth,gMonth,gMonthDayandgDay,compareToGDatetherefore always returned 2 (incomparable). The min check (>= 0) never matched, so the min branch never ran, and the max check (<= 0) let everything through.minInclusive 2100-01-01T00:00:00Zproduced values like2014-01-05T11:16:42.000+00:00.Fix
This also replaces the eight near-identical per-type blocks with one facet lookup.
formatDurationclamps field by field and has similar issues, but this PR leaves it alone.Tests
Xsd2InstTest.testDateSamplesSatisfyTheirBoundsgenerates samples for 12 facet/type combinations and validates each one against its schema. On trunk it fails on the first case. With the fix it passes, and it also passed locally with 2000 iterations per case../gradlew testis green.🤖 Generated with Claude Code