File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 66/// Configuration options for the `ComponentGraph`.
77#[ derive( Clone , Default , Debug ) ]
88pub struct ComponentGraphConfig {
9+ /// Whether to allow validation errors on components. When this is `true`,
10+ /// the graph will be built even if there are validation errors on
11+ /// components.
12+ pub allow_component_validation_failures : bool ,
13+
914 /// Whether to allow unconnected components in the graph, that are not
1015 /// reachable from the root.
1116 pub allow_unconnected_components : bool ,
Original file line number Diff line number Diff line change 5555 ] {
5656 if let Err ( e) = result {
5757 errors. push ( e) ;
58- validation_failed = true ;
58+ validation_failed = ! self . config . allow_component_validation_failures ;
5959 }
6060 }
6161 match errors. len ( ) {
Original file line number Diff line number Diff line change @@ -275,6 +275,7 @@ r#"InvalidGraph: Multiple validation failures:
275275 TestConnection :: new( 2 , 3 ) ,
276276 TestConnection :: new( 3 , 4 ) ,
277277 ] ;
278+ // With default config, this validation fails
278279 assert ! (
279280 ComponentGraph :: try_new( components. clone( ) , connections. clone( ) , config. clone( ) )
280281 . is_err_and( |e| {
@@ -283,6 +284,16 @@ r#"InvalidGraph: Multiple validation failures:
283284 )
284285 } ) ,
285286 ) ;
287+ // With `allow_component_validation_failures=true`, this would pass.
288+ assert ! ( ComponentGraph :: try_new(
289+ components. clone( ) ,
290+ connections. clone( ) ,
291+ ComponentGraphConfig {
292+ allow_component_validation_failures: true ,
293+ ..config. clone( )
294+ }
295+ )
296+ . is_ok( ) ) ;
286297
287298 components. pop ( ) ;
288299 connections. pop ( ) ;
You can’t perform that action at this time.
0 commit comments