anweiss / cddl

Concise data definition language (RFC 8610) implementation and JSON and CBOR validator in Rust
https://cddl.anweiss.tech
MIT License
91 stars 13 forks source link

tdate not validating as I'd expect #183

Closed chalford closed 1 year ago

chalford commented 1 year ago

I'm relatively inexperienced with CBOR & CDDL, so I may be interpreting the spec incorrectly, but I'm having a problem with the tdate type.

CDDL file:

root = tdate

CBOR file (as CBOR-Diag)

0("2020-02-11T09:00:00Z")

CBOR file (as base64)

dDIwMjAtMDItMTFUMDk6MDA6MDBa

My understanding was that a tdate was defined as #6.0(tstr), which is a tstr with a tag of 0. When I run validation with the above files, I get the following validation error:

[ERROR] Validation of "date.cbor" failed: error validating at cbor location : expected type tdate, got Tag(0, Text("2020-02-11T09:00:00Z"))

anweiss commented 1 year ago

Good catch @chalford! Working on a fix

anweiss commented 1 year ago

Fixed in #186.

chalford commented 1 year ago

Thank you!