Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choice validates in case where neither option validates #174

Open
jgraham opened this issue Jan 26, 2023 · 0 comments
Open

Choice validates in case where neither option validates #174

jgraham opened this issue Jan 26, 2023 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jgraham
Copy link

jgraham commented Jan 26, 2023

I have some CDDL like

Root = Choice1 / Choice2

Choice1 = {
   id1: text,
   ?id2: text,
   Extensible
}

Choice2 = {
   ?id1: text,
   id2: text,
   Extensible
}

Extensible = (*text => any)

That may look a bit strange; in the broader context it's trying to express that the data must either have id1 or id2 or both, and that in any case the values of the id1 and id2 items must be text.

The problem is that with cddl validate the following JSON is accepted:

{
"id1": "example",
"id2": 2
}

Changing the Root to either Choice1 or Choice2 alone causes the validation to fail as expected. Changing the input to a JSON object that's missing either id1 or id2 also fails as expected.

Apologies if I've misunderstood how CDDL is supposed to work in this case, but it seems like possibly a bug in the handling of cuts and choices?

@anweiss anweiss self-assigned this Aug 8, 2023
@anweiss anweiss added the bug Something isn't working label Aug 8, 2023
@anweiss anweiss added this to the v1.0.0 milestone Aug 8, 2023
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

No branches or pull requests

2 participants