Use more appropriate object type for validation

This commit is contained in:
Hanno Braun 2023-04-27 10:29:41 +02:00
parent 137c2d3e70
commit e65c030472
3 changed files with 13 additions and 13 deletions

View File

@ -31,6 +31,15 @@ macro_rules! object {
)*
}
}
/// Validate the object
pub fn validate(&self, errors: &mut Vec<ValidationError>) {
match self {
$(
Self::$ty(object) => object.validate(errors),
)*
}
}
}
impl Object<WithHandle> {
@ -47,15 +56,6 @@ macro_rules! object {
)*
}
}
/// Validate the object
pub fn validate(&self, errors: &mut Vec<ValidationError>) {
match self {
$(
Self::$ty((_, object)) => object.validate(errors),
)*
}
}
}
impl From<Object<WithHandle>> for Object<BehindHandle> {

View File

@ -47,7 +47,7 @@ impl Services {
for object_event in object_events {
let command = ValidationCommand::ValidateObject {
object: object_event.object,
object: object_event.object.into(),
};
self.validation.execute(command, &mut Vec::new());
}

View File

@ -1,7 +1,7 @@
use std::{collections::BTreeMap, thread};
use crate::{
objects::{BehindHandle, Object, WithHandle},
objects::{BehindHandle, Object},
storage::ObjectId,
validate::ValidationError,
};
@ -44,7 +44,7 @@ impl State for Validation {
for err in errors {
events.push(ValidationFailed {
object: object.clone().into(),
object: object.clone(),
err,
});
}
@ -60,7 +60,7 @@ pub enum ValidationCommand {
/// Validate the provided object
ValidateObject {
/// The object to validate
object: Object<WithHandle>,
object: Object<BehindHandle>,
},
}