Add get_fields_to_validate_for_member()
This commit is contained in:
parent
efa0b8fe69
commit
76eb1ffc3f
@ -140,6 +140,30 @@ impl ProcessState {
|
||||
self.encrypted_pcd == Value::Null ||
|
||||
self.pcd_commitment == Value::Null
|
||||
}
|
||||
|
||||
pub fn get_fields_to_validate_for_member(&self, member: &Member) -> anyhow::Result<Vec<String>> {
|
||||
let decrypted = self.decrypt_pcd()?;
|
||||
|
||||
let roles = decrypted.extract_roles()?;
|
||||
|
||||
let mut res: HashSet<String> = HashSet::new();
|
||||
|
||||
// Are we in that role?
|
||||
for (_, role_def) in roles {
|
||||
if !role_def.members.contains(member) {
|
||||
continue;
|
||||
} else {
|
||||
// what are the fields we can modify?
|
||||
for rule in role_def.validation_rules {
|
||||
if rule.allows_modification() {
|
||||
res.extend(rule.fields.iter().map(|f| f.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(res.into_iter().collect())
|
||||
}
|
||||
}
|
||||
|
||||
/// A process is basically a succession of states
|
||||
|
Loading…
x
Reference in New Issue
Block a user