decentralized-identity / presentation-exchange

Specification that codifies an inter-related pair of data formats for defining proof presentations (Presentation Definition) and subsequent proof submissions (Presentation Submission)
https://identity.foundation/presentation-exchange
Apache License 2.0
86 stars 37 forks source link

Matching on arrays of strings #303

Closed David-Chadwick closed 2 months ago

David-Chadwick commented 2 years ago

If a VC contains a property whose values are a set of strings, e.g.

foo = ["bar", "baz"]

then a presentation definition filter will need to specify one-of or any-of from the array of values e.g.

"path": [
    "$.foo"
],
"filter": {
    "type": "array",
    "items": {
        "type": "string"
    },
    "oneOf": ["foo", "abc"]
}

Unfortunately when the above PD has been entered into the OIDC4VP draft, there is a schema checking violation on the oneOf property (also anyOf gives a similar error). The authors of OIDC4VP feel that this is a problem with the PE specification, in that it is not precise enough about which schema validation rules (year, version) have to be used. Nor is there any indication of which tools exist in order to validate that any PD instance is a correct instance of the PE specification.

csuwildcat commented 2 years ago

As I understand it, the desire is to inspect every element of an array using a JSON Schema filter to test for presence of values.

If you assume the following target object:

{
  "foo": ["bar", "biz"]
}

This would be the filter you would use to evaluate each element of the array to ensure at least one of a specified set of string values is present:

{
  "path": ["$.foo"],
  "filter": {
    "type": "array",
    "contains": {
      "enum": ["bar", "zoo"]
    }
  }
}
JaceHensley commented 2 years ago

Here's the docs for handling tuples with json schema https://json-schema.org/understanding-json-schema/reference/array.html#tuple-validation

csuwildcat commented 2 years ago

Closing as complete, given the requested filter is supported and examples have been provided.

Sakurann commented 5 months ago

why was this closed complete? json schema validation for oid4vp example still fails, no?

JaceHensley commented 5 months ago

I believe this was closed because json schema supports the requested filter. There's nothing PE specific about the json schema capabilities

kimdhamilton commented 2 months ago

Reopening per #480

decentralgabe commented 2 months ago

this should be addressed by specifying Draft 7 here https://github.com/decentralized-identity/presentation-exchange/pull/481

closing this now, please re-open if this solution is insufficient