MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / validate

Method validate

nodedb-crdt/src/validator/validate.rs:18–33  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 ///

Callers 6

pre_validateFunction · 0.45
validate_or_rejectMethod · 0.45
validate_with_policyMethod · 0.45
not_null_violationFunction · 0.45
foreign_key_violationFunction · 0.45

Calls 4

for_collectionMethod · 0.80
check_constraintMethod · 0.80
pushMethod · 0.45
is_emptyMethod · 0.45

Tested by 3

not_null_violationFunction · 0.36
foreign_key_violationFunction · 0.36