backbone_integrations/application/validator/
integration_event_validator.rs1use backbone_core::{EntityValidator, ValidationErrors, ValidationError};
9use backbone_core::{OptionalNotBlank, RequiredString};
10use crate::domain::entity::IntegrationEvent;
11
12pub type IntegrationEventValidator = EntityValidator<IntegrationEvent>;
14
15pub fn integration_event_validator() -> IntegrationEventValidator {
17 EntityValidator::new()
18 .rule(RequiredString::new("event_type", |e: &IntegrationEvent| &e.event_type))
19 .rule(RequiredString::new("external_id", |e: &IntegrationEvent| &e.external_id))
20 .rule(RequiredString::new("business_key", |e: &IntegrationEvent| &e.business_key))
21 .rule(RequiredString::new("payload", |e: &IntegrationEvent| &e.payload))
22 .rule(OptionalNotBlank::new("mapped_ref_type", |e: &IntegrationEvent| e.mapped_ref_type.as_deref()))
23 .rule(OptionalNotBlank::new("error_detail", |e: &IntegrationEvent| e.error_detail.as_deref()))
24 }
27
28