mirror of
https://github.com/hannobraun/Fornjot
synced 2025-11-04 22:20:36 +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> {
|
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> {
|
impl From<Object<WithHandle>> for Object<BehindHandle> {
|
||||||
|
|||||||
@ -47,7 +47,7 @@ impl Services {
|
|||||||
|
|
||||||
for object_event in object_events {
|
for object_event in object_events {
|
||||||
let command = ValidationCommand::ValidateObject {
|
let command = ValidationCommand::ValidateObject {
|
||||||
object: object_event.object,
|
object: object_event.object.into(),
|
||||||
};
|
};
|
||||||
self.validation.execute(command, &mut Vec::new());
|
self.validation.execute(command, &mut Vec::new());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use std::{collections::BTreeMap, thread};
|
use std::{collections::BTreeMap, thread};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
objects::{BehindHandle, Object, WithHandle},
|
objects::{BehindHandle, Object},
|
||||||
storage::ObjectId,
|
storage::ObjectId,
|
||||||
validate::ValidationError,
|
validate::ValidationError,
|
||||||
};
|
};
|
||||||
@ -44,7 +44,7 @@ impl State for Validation {
|
|||||||
|
|
||||||
for err in errors {
|
for err in errors {
|
||||||
events.push(ValidationFailed {
|
events.push(ValidationFailed {
|
||||||
object: object.clone().into(),
|
object: object.clone(),
|
||||||
err,
|
err,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -60,7 +60,7 @@ pub enum ValidationCommand {
|
|||||||
/// Validate the provided object
|
/// Validate the provided object
|
||||||
ValidateObject {
|
ValidateObject {
|
||||||
/// The object to validate
|
/// The object to validate
|
||||||
object: Object<WithHandle>,
|
object: Object<BehindHandle>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user