Skip to content

Validation parity with vcon 1.0.4 (content_hash, lawful basis body, created_at) - #9

Merged
howethomas merged 1 commit into
mainfrom
validation-parity-1.0.4
Nov 19, 2026
Merged

howethomas merged 1 commit into
mainfrom
validation-parity-1.0.4

Conversation

@howethomas

Copy link
Copy Markdown
Contributor

Brings isValid() / getValidationWarnings() to parity with the Python reference, vcon 1.0.4, using the same messages.

Rules ported

  • content_hash form (contentHashProblems(), exported): errors for a ContentHash that is not <algorithm>-<base64url digest>, an empty list, a non-string, or a sha512/sha256 digest of the wrong length. Checked on Dialogs (except incomplete), attachments, analysis, redacted_from and amended_from.
  • Warnings: url without content_hash on a Dialog, analysis, or inline/redacted attachment (an error in 1.1), and a serialized JSON string body under encoding: "json".
  • Lawful basis body validator (src/lawful-basis.ts, a port of LawfulBasisValidator): required fields, lawful basis value, expiration, purpose grants, content_hash object, proof mechanisms, and registry. isValid() runs it on every purpose: "lawful_basis" attachment. Its errors and warnings are prefixed Attachment at index N (lawful_basis): and its own scope warnings are left out. Unknown proof types, hash algorithms, and canonicalization methods are warnings. Nested warnings are passed up. Timestamps are parsed the way Python's datetime.fromisoformat parses them.
  • created_at is kept as written on load. A missing or empty value is set to now. An unparseable created_at/updated_at error now gives the reason in dateutil's wording.
  • Removed the JS-only lawful_basis attachment ... has no party/session warnings. Python does not emit them, and the core rules already check scope.

Parity

Compared against vcon==1.0.4 on 257 vCons (migrated real-world vCons plus the core-05 Appendix B examples), with migrate_legacy=False:

verdicts errors warnings
before 243 78 9
after 255 255 257

The two files that still differ are B6/B7, the known JWS-form difference. I also ran 147 generated edge cases. All match except 7, and each of those is a Python bug where JS deliberately behaves differently: is_valid() raises on some inputs, and Python accepts a ContentHash with a trailing newline.

Test fixtures that used sha512-x now use a real digest, as the Python tests do.

@howethomas
howethomas merged commit ad4d443 into main Nov 19, 2026
2 checks passed
@howethomas
howethomas deleted the validation-parity-1.0.4 branch November 19, 2026 01:08
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.

1 participant