Skip to content

🐛 fix(validate): enforce range facets on g* dates - #2279

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/xsd-gyear-order-1888
Nov 16, 2026
Merged

gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/xsd-gyear-order-1888

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

Range facets on xs:gYear, xs:gYearMonth, xs:gMonth, xs:gMonthDay and xs:gDay did not constrain values, so a schema that bounded one of these types accepted values outside the window it stated. Once this merges, those five types are checked against their bounds in the order XML Schema 1.1 gives them, and out-of-window values fail. Fixes #2278.

The order that already covers xs:date, xs:dateTime, xs:time and xs:duration now covers the five partial types too. A value that leaves out its year, month or day is placed on the timeline with those fields taken from 1972-12-31, the reference that XML Schema 1.1 Part 2, appendix D.2.1 gives for absent components, and a missing day takes the last day of its month. A value with a timezone is ordered against one without only when the order holds for every offset within fourteen hours, the rule xs:dateTime already follows. Schemas that never bound these types see no change.

Behavior changes

  • Values of the five types outside a range facet's window now fail in both XMLSchema and RelaxNG, so documents that validated before can now be invalid.
  • A value the order does not place against a bound fails that facet, including a value with a timezone that lies within fourteen hours of an unzoned bound.
  • The validate reference no longer lists these types as unchecked.

Range facets on xs:gYear, xs:gYearMonth, xs:gMonth, xs:gMonthDay and
xs:gDay were checked as plain strings, so a value outside the bound
passed. These types now have an order: a field the value leaves out
takes its value from 1972-12-31, and a missing day takes the last day
of its month (XSD 1.1 Part 2, appendix D.2.1). A value with a timezone
is ordered against one without only when the result holds for every
offset within fourteen hours, as it already is for dateTime.
@gaborbernat gaborbernat added the bug Something isn't working label Nov 16, 2026
@gaborbernat
gaborbernat merged commit 77ac7ae into tox-dev:main Nov 16, 2026
2 of 48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XML Schema range facets are not enforced on g* date types

1 participant