diff --git a/src/core/presentation_definition.rs b/src/core/presentation_definition.rs index 0365fac..2b9402b 100644 --- a/src/core/presentation_definition.rs +++ b/src/core/presentation_definition.rs @@ -223,23 +223,19 @@ impl PresentationDefinition { .filter(|field| field.is_required()) .all(|field| { match field.filter.as_ref().map(|f| f.validator()) { - Some(validator) => { - let is_valid = field - .path - .iter() - // NOTE: Errors are ignored to allow other paths to - // be checked. Interested in whether there is at least - // one valid path. - // - // An empty iterator will return false on an any() call. - .flat_map(|path| path.query(credential)) - // NOTE: This is currently assuming that if any of the paths are a match - // to the credential, then the validation is, at least partially, successful, - // and the credential may satisfy the presentation definition. - .any(|value| validator.validate(value).is_ok()); - - is_valid - } + Some(validator) => field + .path + .iter() + .flat_map(|path| path.query(credential)) + .any(|value| { + if let serde_json::Value::Array(vals) = value { + if vals.iter().any(|val| validator.validate(val).is_ok()) { + return true; + } + } + + validator.validate(value).is_ok() + }), // Allow for fields without validators to pass through. _ => true, }