diff --git a/crates/fj-core/src/layers/validation.rs b/crates/fj-core/src/layers/validation.rs index 52adb3aea..a3ac931d3 100644 --- a/crates/fj-core/src/layers/validation.rs +++ b/crates/fj-core/src/layers/validation.rs @@ -22,7 +22,7 @@ impl Command for InsertObject { let mut errors = Vec::new(); let object: AnyObject = self.object.into(); - object.validate_with_config(&state.config, &mut errors); + object.validate(&state.config, &mut errors); for err in errors { events.push(ValidationFailed { diff --git a/crates/fj-core/src/objects/any_object.rs b/crates/fj-core/src/objects/any_object.rs index ad2bd769e..6c047e2e2 100644 --- a/crates/fj-core/src/objects/any_object.rs +++ b/crates/fj-core/src/objects/any_object.rs @@ -34,23 +34,14 @@ macro_rules! any_object { } } - /// Validate the object - pub fn validate(&self, errors: &mut Vec) { - match self { - $( - Self::$ty(object) => object.validate(errors), - )* - } - } - /// Validate the object with a pre-defined validation configuration - pub fn validate_with_config(&self, + pub fn validate(&self, config: &ValidationConfig, errors: &mut Vec ) { match self { $( - Self::$ty(object) => object.validate_with_config(config, errors), + Self::$ty(object) => object.validate(config, errors), )* } } diff --git a/crates/fj-core/src/validate/curve.rs b/crates/fj-core/src/validate/curve.rs index e5ce4147c..19b910d8d 100644 --- a/crates/fj-core/src/validate/curve.rs +++ b/crates/fj-core/src/validate/curve.rs @@ -6,10 +6,5 @@ use crate::{ use super::Validate; impl Validate for Curve { - fn validate_with_config( - &self, - _: &ValidationConfig, - _: &mut Vec, - ) { - } + fn validate(&self, _: &ValidationConfig, _: &mut Vec) {} } diff --git a/crates/fj-core/src/validate/cycle.rs b/crates/fj-core/src/validate/cycle.rs index e4e924fca..035d46781 100644 --- a/crates/fj-core/src/validate/cycle.rs +++ b/crates/fj-core/src/validate/cycle.rs @@ -9,7 +9,7 @@ use crate::{ use super::Validate; impl Validate for Cycle { - fn validate_with_config( + fn validate( &self, config: &ValidationConfig, errors: &mut Vec, diff --git a/crates/fj-core/src/validate/edge.rs b/crates/fj-core/src/validate/edge.rs index ff6a925e5..6f1e598b0 100644 --- a/crates/fj-core/src/validate/edge.rs +++ b/crates/fj-core/src/validate/edge.rs @@ -8,7 +8,7 @@ use crate::{ use super::Validate; impl Validate for HalfEdge { - fn validate_with_config( + fn validate( &self, config: &ValidationConfig, errors: &mut Vec, diff --git a/crates/fj-core/src/validate/face.rs b/crates/fj-core/src/validate/face.rs index 4df3ce2ed..94ded4be0 100644 --- a/crates/fj-core/src/validate/face.rs +++ b/crates/fj-core/src/validate/face.rs @@ -8,7 +8,7 @@ use crate::{ use super::Validate; impl Validate for Face { - fn validate_with_config( + fn validate( &self, _: &ValidationConfig, errors: &mut Vec, diff --git a/crates/fj-core/src/validate/mod.rs b/crates/fj-core/src/validate/mod.rs index 02841dd0b..295ca5224 100644 --- a/crates/fj-core/src/validate/mod.rs +++ b/crates/fj-core/src/validate/mod.rs @@ -49,7 +49,7 @@ //! that are very close together can be considered coincident. What should be //! considered "very close" is dependent on the scale that your model operates //! on, and this fact is taken into account by allowing for configuration via -//! [`Validate::validate_with_config`] and [`ValidationConfig`]. +//! [`Validate::validate`] and [`ValidationConfig`]. //! //! //! ## Implementation Note @@ -88,7 +88,10 @@ macro_rules! assert_contains_err { ($o:tt,$p:pat) => { assert!({ let mut errors = Vec::new(); - $o.validate(&mut errors); + $o.validate( + &$crate::validation::ValidationConfig::default(), + &mut errors, + ); errors.iter().any(|e| matches!(e, $p)) }) }; @@ -102,7 +105,7 @@ pub trait Validate: Sized { #[allow(clippy::result_large_err)] fn validate_and_return_first_error(&self) -> Result<(), ValidationError> { let mut errors = Vec::new(); - self.validate(&mut errors); + self.validate(&ValidationConfig::default(), &mut errors); if let Some(err) = errors.into_iter().next() { return Err(err); @@ -111,13 +114,8 @@ pub trait Validate: Sized { Ok(()) } - /// Validate the object using default configuration - fn validate(&self, errors: &mut Vec) { - self.validate_with_config(&ValidationConfig::default(), errors) - } - /// Validate the object - fn validate_with_config( + fn validate( &self, config: &ValidationConfig, errors: &mut Vec, diff --git a/crates/fj-core/src/validate/region.rs b/crates/fj-core/src/validate/region.rs index 3cd0ae87b..d8b6bbf32 100644 --- a/crates/fj-core/src/validate/region.rs +++ b/crates/fj-core/src/validate/region.rs @@ -3,10 +3,5 @@ use crate::objects::Region; use super::{Validate, ValidationConfig, ValidationError}; impl Validate for Region { - fn validate_with_config( - &self, - _: &ValidationConfig, - _: &mut Vec, - ) { - } + fn validate(&self, _: &ValidationConfig, _: &mut Vec) {} } diff --git a/crates/fj-core/src/validate/shell.rs b/crates/fj-core/src/validate/shell.rs index 5dba7492c..b9b9b45f0 100644 --- a/crates/fj-core/src/validate/shell.rs +++ b/crates/fj-core/src/validate/shell.rs @@ -14,7 +14,7 @@ use crate::{ use super::{Validate, ValidationConfig, ValidationError}; impl Validate for Shell { - fn validate_with_config( + fn validate( &self, config: &ValidationConfig, errors: &mut Vec, diff --git a/crates/fj-core/src/validate/sketch.rs b/crates/fj-core/src/validate/sketch.rs index 7de935d23..425e6812c 100644 --- a/crates/fj-core/src/validate/sketch.rs +++ b/crates/fj-core/src/validate/sketch.rs @@ -6,7 +6,7 @@ use super::{ }; impl Validate for Sketch { - fn validate_with_config( + fn validate( &self, config: &ValidationConfig, errors: &mut Vec, diff --git a/crates/fj-core/src/validate/solid.rs b/crates/fj-core/src/validate/solid.rs index befa649eb..b0bf01d85 100644 --- a/crates/fj-core/src/validate/solid.rs +++ b/crates/fj-core/src/validate/solid.rs @@ -13,7 +13,7 @@ use super::{ }; impl Validate for Solid { - fn validate_with_config( + fn validate( &self, config: &ValidationConfig, errors: &mut Vec, diff --git a/crates/fj-core/src/validate/surface.rs b/crates/fj-core/src/validate/surface.rs index 4462f9147..4cb39c1be 100644 --- a/crates/fj-core/src/validate/surface.rs +++ b/crates/fj-core/src/validate/surface.rs @@ -3,10 +3,5 @@ use crate::objects::Surface; use super::{Validate, ValidationConfig, ValidationError}; impl Validate for Surface { - fn validate_with_config( - &self, - _: &ValidationConfig, - _: &mut Vec, - ) { - } + fn validate(&self, _: &ValidationConfig, _: &mut Vec) {} } diff --git a/crates/fj-core/src/validate/vertex.rs b/crates/fj-core/src/validate/vertex.rs index 029f79f1d..1e2e7e700 100644 --- a/crates/fj-core/src/validate/vertex.rs +++ b/crates/fj-core/src/validate/vertex.rs @@ -3,10 +3,5 @@ use crate::objects::Vertex; use super::{Validate, ValidationConfig, ValidationError}; impl Validate for Vertex { - fn validate_with_config( - &self, - _: &ValidationConfig, - _: &mut Vec, - ) { - } + fn validate(&self, _: &ValidationConfig, _: &mut Vec) {} }