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
85 stars 37 forks source link

Filter By Credential Type #337

Closed fabian-hk closed 2 years ago

fabian-hk commented 2 years ago

I would like to know how to filter for a certain credential type. The example "Filter By Credential Type" in section 5 is a bit unclear to me because the filter filters for a single string. As far as I know, the type property is usually an array with two or more items. Shouldn't this be a JSON Schema that matches an array? Preferable an array with only the elements I want to have in there without additional elements?

csuwildcat commented 2 years ago

You would check that the URI/string of the type value you are expecting is within the credential's type property, like this:

Type array must contain one specific value:

"constraints": {
  "fields": [
    {
      "path": [ "$.type" ],
      "filter": {
        "type": "array",
        "contains": {
          "enum": ["https://example.com/type"]
        }
      }
    }
  ]
}

Type array must contain two different values:

"constraints": {
  "fields": [
    {
      "path": [ "$.type" ],
      "filter": {
        "type": "array",
        "allOf": [
            { "contains": { "enum": ["https://example.com/type"] } },
            { "contains": { "enum": ["SomeTypeString"] } }
          ]
      }
    }
  ]
}
fabian-hk commented 2 years ago

Thank you for the examples!