@@ -54,7 +54,8 @@ type InputDescriptorMapping struct {
5454
5555// MatchOptions is a holder of options that can set when matching a submission against definitions.
5656type MatchOptions struct {
57- CredentialOptions []verifiable.CredentialOpt
57+ CredentialOptions []verifiable.CredentialOpt
58+ DisableSchemaValidation bool
5859}
5960
6061// MatchOption is an option that sets an option for when matching.
@@ -67,6 +68,13 @@ func WithCredentialOptions(options ...verifiable.CredentialOpt) MatchOption {
6768 }
6869}
6970
71+ // WithDisableSchemaValidation used to disable schema validation.
72+ func WithDisableSchemaValidation () MatchOption {
73+ return func (m * MatchOptions ) {
74+ m .DisableSchemaValidation = true
75+ }
76+ }
77+
7078// Match returns the credentials matched against the InputDescriptors ids.
7179func (pd * PresentationDefinition ) Match (vp * verifiable.Presentation , // nolint:gocyclo,funlen
7280 contextLoader ld.DocumentLoader , options ... MatchOption ) (map [string ]* verifiable.Credential , error ) {
@@ -113,6 +121,9 @@ func (pd *PresentationDefinition) Match(vp *verifiable.Presentation, // nolint:g
113121 descriptorMapProperty , mapping .ID )
114122 }
115123
124+ // TODO need to revisit this logic
125+ mapping = pd .getPathNestedIfExists (mapping )
126+
116127 vc , selectErr := selectByPath (builder , typelessVP , mapping .Path , opts )
117128 if selectErr != nil {
118129 return nil , fmt .Errorf ("failed to select vc from submission: %w" , selectErr )
@@ -121,7 +132,7 @@ func (pd *PresentationDefinition) Match(vp *verifiable.Presentation, // nolint:g
121132 inputDescriptor := pd .inputDescriptor (mapping .ID )
122133
123134 passed := filterSchema (inputDescriptor .Schema , []* verifiable.Credential {vc }, contextLoader )
124- if len (passed ) == 0 {
135+ if len (passed ) == 0 && ! opts . DisableSchemaValidation {
125136 return nil , fmt .Errorf (
126137 "input descriptor id [%s] requires schemas %+v which do not match vc with @context [%+v] and types [%+v] selected by path [%s]" , // nolint:lll
127138 inputDescriptor .ID , inputDescriptor .Schema , vc .Context , vc .Types , mapping .Path )
@@ -140,6 +151,14 @@ func (pd *PresentationDefinition) Match(vp *verifiable.Presentation, // nolint:g
140151 return result , nil
141152}
142153
154+ func (pd * PresentationDefinition ) getPathNestedIfExists (mapping * InputDescriptorMapping ) * InputDescriptorMapping {
155+ if mapping .PathNested != nil {
156+ return pd .getPathNestedIfExists (mapping .PathNested )
157+ }
158+
159+ return mapping
160+ }
161+
143162// Ensures the matched credentials meet the submission requirements.
144163func (pd * PresentationDefinition ) evalSubmissionRequirements (matched map [string ]* verifiable.Credential ) error {
145164 // TODO support submission requirement rules: https://github.com/hyperledger/aries-framework-go/issues/2109
0 commit comments