reactive_graph_behaviour_model_impl/behaviour/relation/
validation.rs1use reactive_graph_behaviour_model_api::prelude::*;
2
3use reactive_graph_graph::RelationInstanceId;
4use reactive_graph_reactive_model_api::ReactiveInstanceContainer;
5use reactive_graph_reactive_model_api::ReactivePropertyContainer;
6use reactive_graph_reactive_model_impl::ReactiveRelation;
7
8pub trait RelationPropertyValidator: ReactiveInstanceContainer<RelationInstanceId, ReactiveRelation> {
9 fn validate_outbound_property(&self, property_name: &str) -> Result<(), BehaviourPropertyInvalid> {
11 if !self.get_reactive_instance().outbound.has_property(property_name) {
12 return Err(BehaviourPropertyInvalid::OutboundPropertyMissing(property_name.to_owned()));
13 }
14 Ok(())
15 }
16
17 fn validate_inbound_property(&self, property_name: &str) -> Result<(), BehaviourPropertyInvalid> {
19 if !self.get_reactive_instance().inbound.has_property(property_name) {
20 return Err(BehaviourPropertyInvalid::InboundPropertyMissing(property_name.to_owned()));
21 }
22 Ok(())
23 }
24}