PEX icon indicating copy to clipboard operation
PEX copied to clipboard

chore: Allow array matching

Open sanderPostma opened this issue 1 year ago • 3 comments

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  • What is the current behavior? (You can also link to an open issue here)

  • What is the new behavior (if this is a feature change)?

  • Other information:

sanderPostma avatar Sep 30 '24 20:09 sanderPostma

@nklomp Does this make sense for supporting the following PD?

         "constraints": {
            "fields": [
               {
                  "path": [
                     "$.type",
                     "$.vc.type[*]"
                  ],
                  "filter": {
                     "type": "string",
                     "pattern": "Woonplaatsverklaring"
                  }
               }
            ]
         }

The value of "$.vc.type[*]" is an array

0: "VerifiableCredential"
1: "Woonplaatsverklaring"

Or should this have been working differently?

sanderPostma avatar Sep 30 '24 20:09 sanderPostma

Huh, I would expect that filter to explode that array into separate strings. Only if you would list $.vc.type I would expect it to be an array. You need to look into the jsonpath spec for how it interprets the above, but I would expect you can match $.arrayExanple[*] against a string

nklomp avatar Sep 30 '24 20:09 nklomp

Probably that whole expression needs to be something more like

path: [ '$.vc.type' ], filter: { type: 'array', contains: { const: 'TypeToSearchFor' } }

nklomp avatar Sep 30 '24 20:09 nklomp