mirror of
https://github.com/hannobraun/Fornjot
synced 2025-10-27 18:28:17 +00:00
Use more appropriate object type for validation
This commit is contained in:
parent
137c2d3e70
commit
e65c030472
@ -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> {
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
@ -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>,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user