reactive_graph_std_connector/behaviour/relation/connector/
validator.rs

1use reactive_graph_behaviour_model_api::behaviour_validator;
2use reactive_graph_behaviour_model_api::prelude::*;
3use reactive_graph_behaviour_model_impl::RelationPropertyValidator;
4use reactive_graph_graph::prelude::*;
5use reactive_graph_reactive_model_impl::ReactiveRelation;
6
7use reactive_graph_std_connector_model::ConnectorProperties::INBOUND_PROPERTY_NAME;
8use reactive_graph_std_connector_model::ConnectorProperties::OUTBOUND_PROPERTY_NAME;
9
10behaviour_validator!(ConnectorValidator, RelationInstanceId, ReactiveRelation);
11
12impl BehaviourPropertyValidator<RelationInstanceId, ReactiveRelation> for ConnectorValidator {
13    fn validate_properties(&self) -> Result<(), BehaviourPropertyInvalid> {
14        self.validate_property(OUTBOUND_PROPERTY_NAME.as_ref())?;
15        self.validate_property(INBOUND_PROPERTY_NAME.as_ref())?;
16        // Dynamically validate if the properties of the outbound and inbound instances.
17        let outbound_property_name = self
18            .reactive_instance
19            .as_string(OUTBOUND_PROPERTY_NAME.as_ref())
20            .ok_or(BehaviourPropertyInvalid::PropertyMissing(OUTBOUND_PROPERTY_NAME.to_string()))?;
21        self.validate_outbound_property(&outbound_property_name)?;
22        let inbound_property_name = self
23            .reactive_instance
24            .as_string(INBOUND_PROPERTY_NAME.as_ref())
25            .ok_or(BehaviourPropertyInvalid::PropertyMissing(INBOUND_PROPERTY_NAME.to_string()))?;
26        self.validate_inbound_property(&inbound_property_name)?;
27        Ok(())
28    }
29}
30
31impl RelationPropertyValidator for ConnectorValidator {}