From 97309038034be8cb77c4aa1be49118e689676df3 Mon Sep 17 00:00:00 2001 From: Mihaela Mihaljevic Date: Tue, 9 Jun 2026 08:50:39 +0200 Subject: [PATCH] fix(xsd): locate identity-constraint errors at their element The IdentityValidator emitted every key/keyref/unique error with an empty coding path (at: []), so each rendered "at root of document" regardless of which element violated the constraint. Thread a [PathKey] through the walk, the way the content-model validator already does, so the failures carry the constraining element's path. This restores the validation framework's path-carrying contract for the one rule that was bypassing it. --- CHANGELOG.md | 1 + README.md | 2 +- Sources/Schema/IdentityValidator.swift | 47 ++++++++++++++++++++------ Sources/Schema/XSDValidations.swift | 5 +-- Tests/XSDIdentityTests.swift | 21 ++++++++++++ 5 files changed, 62 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d7410e..433f10f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +- XSD identity-constraint errors (`key`, `keyref`, `unique`) now carry a coding path locating the constraining element, instead of always rendering "at root of document". The `IdentityValidator` walk threads a `[PathKey]` the same way the content-model validator does, so a duplicate-key or dangling-keyref failure reports "... at path: list" rather than an empty path. This brings the identity-constraint rule into line with the validation framework's path-carrying contract, which every other rule already honored. - A `