Skip to content

Commit

Permalink
Added functionality to use optional validation config if it is define…
Browse files Browse the repository at this point in the history
…d to the validation service, and added validate_with_config() method to object.rs
  • Loading branch information
brungardtdb committed Dec 23, 2023
1 parent 268a1c4 commit 4f8be06
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
11 changes: 10 additions & 1 deletion crates/fj-core/src/objects/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
Surface, Vertex,
},
storage::{Handle, HandleWrapper, ObjectId},
validate::{Validate, ValidationError},
validate::{Validate, ValidationConfig, ValidationError},
};

macro_rules! object {
Expand Down Expand Up @@ -40,6 +40,15 @@ macro_rules! object {
)*
}
}

/// Validate the object with a pre-defined validation configuration
pub fn validate_with_config(&self, config: &ValidationConfig, errors: &mut Vec<ValidationError>) {
match self {
$(
Self::$ty(object) => object.validate_with_config(config, errors),
)*
}
}
}

impl Object<WithHandle> {
Expand Down
4 changes: 4 additions & 0 deletions crates/fj-core/src/services/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ impl State for Validation {

match command {
ValidationCommand::ValidateObject { object } => {
match self.config {
Some(c) => object.validate_with_config(&c, &mut errors),
None => object.validate(&mut errors),
}
object.validate(&mut errors);

for err in errors {
Expand Down

0 comments on commit 4f8be06

Please sign in to comment.