Validate a proposed change against all applicable constraints. Returns `Accepted` if all constraints pass, or `Rejected` with detailed violation information.
(&self, state: &CrdtState, change: &ProposedChange)
| 16 | /// Returns `Accepted` if all constraints pass, or `Rejected` with |
| 17 | /// detailed violation information. |
| 18 | pub fn validate(&self, state: &CrdtState, change: &ProposedChange) -> ValidationOutcome { |
| 19 | let constraints = self.constraints.for_collection(&change.collection); |
| 20 | let mut violations = Vec::new(); |
| 21 | |
| 22 | for constraint in constraints { |
| 23 | if let Some(violation) = self.check_constraint(state, change, constraint) { |
| 24 | violations.push(violation); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | if violations.is_empty() { |
| 29 | ValidationOutcome::Accepted |
| 30 | } else { |
| 31 | ValidationOutcome::Rejected(violations) |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | /// Validate and apply declarative policy resolution. |
| 36 | /// |