mjhm / lodash-match-pattern

Deep JSON pattern matching library
MIT License
50 stars 3 forks source link

Match partial property names? #44

Open robross0606 opened 3 years ago

robross0606 commented 3 years ago

I need to match a structure where a property key starts with a value and the object inside the property has a value. For example:

  resourceContext: {
    Study: {
      id: 'studies-h8AnviS5Bo:z5fhyQSHyg0',
      revision: '_coWZKOm---',
      contextIndex: 0,
      standardsCollectionId: '1.0_1607995913870-103086266',
      compound: 'X',
      therapeuticArea: 'ast',
      indication: 'not good',
      studyPhase: 'Phase 1',
      studyType: 'weapons',
      participantType: 'patient',
      ownerId: 'demo',
      organization: 'demo org'
    },
    Workflow_Study_delete: {
      id: 'RT0AQsbuYR',
      revision: '2021-07-14T17:40:26.440Z',
      state: 'deleted',
      contextIndex: 1
    }
  }

In this case, I need to match any resourceContext which has a property that starts with "Workflow_" and that property contains a string value on state.

The rest is easy, but is it possible to match the "Workflow_Study_delete" property without knowing the full property name?