From 4f8be06aeac030cb74400a5e2c0dbf149dca76f2 Mon Sep 17 00:00:00 2001 From: David Brungardt <34960989+brungardtdb@users.noreply.github.com> Date: Sat, 23 Dec 2023 09:40:33 -0600 Subject: [PATCH] Added functionality to use optional validation config if it is defined to the validation service, and added validate_with_config() method to object.rs --- crates/fj-core/src/objects/object.rs | 11 ++++++++++- crates/fj-core/src/services/validation.rs | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/fj-core/src/objects/object.rs b/crates/fj-core/src/objects/object.rs index 3cddf3f7ae..c303532c9e 100644 --- a/crates/fj-core/src/objects/object.rs +++ b/crates/fj-core/src/objects/object.rs @@ -4,7 +4,7 @@ use crate::{ Surface, Vertex, }, storage::{Handle, HandleWrapper, ObjectId}, - validate::{Validate, ValidationError}, + validate::{Validate, ValidationConfig, ValidationError}, }; macro_rules! object { @@ -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) { + match self { + $( + Self::$ty(object) => object.validate_with_config(config, errors), + )* + } + } } impl Object { diff --git a/crates/fj-core/src/services/validation.rs b/crates/fj-core/src/services/validation.rs index c40cce03df..6f674a3415 100644 --- a/crates/fj-core/src/services/validation.rs +++ b/crates/fj-core/src/services/validation.rs @@ -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 {