Skip to content

Commit

Permalink
test the constraint against each array element
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Tate <[email protected]>
  • Loading branch information
Ryanmtate committed Dec 16, 2024
1 parent 8797db8 commit 335c843
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/core/presentation_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,12 @@ impl PresentationDefinition {
.iter()
.flat_map(|path| path.query(credential))
.any(|value| {
match value {
// If the value is an array, test the constraint against each array element.
serde_json::Value::Array(vals) => {
if vals.iter().any(|val| validator.validate(val).is_ok()) {
return true;
}
},
_ => (),
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.
Expand Down

0 comments on commit 335c843

Please sign in to comment.