@@ -20,6 +20,7 @@ public void Passes_all_validation_no_children()
2020 Items = new List < ItemExample > ( ) ,
2121 ItemsList = new List < ItemExample > ( ) ,
2222 ItemsCollection = new List < ItemExample > ( ) ,
23+ ItemWithListExamples = new List < ItemWithListExample > ( ) ,
2324 } ;
2425
2526 var validationResults = new List < ValidationResult > ( ) ;
@@ -110,7 +111,19 @@ public void Passes_all_validation_with_children()
110111 ExampleEnumD = ExampleEnum . ValueA
111112 }
112113 }
113- }
114+ } ,
115+ ItemWithListExamples = new List < ItemWithListExample >
116+ {
117+ new ItemWithListExample
118+ {
119+ ItemWithListName = "ItemList 0L" ,
120+ Claims = new List < string >
121+ {
122+ "Claim 0L-1" ,
123+ "Claim 0L-2" ,
124+ } ,
125+ } ,
126+ } ,
114127 } ;
115128
116129 var validationResults = new List < ValidationResult > ( ) ;
@@ -284,7 +297,46 @@ public void Fails_on_Items_Child2_SimpleA_BoolC()
284297 ExampleEnumD = ExampleEnum . ValueA
285298 }
286299 } ,
287- }
300+ } ,
301+ ItemWithListExamples = new List < ItemWithListExample >
302+ {
303+ new ItemWithListExample
304+ {
305+ ItemWithListName = null ,
306+ Claims = new List < string >
307+ {
308+ null ,
309+ "ItemList Claim 0L-1L" ,
310+ } ,
311+ } ,
312+ new ItemWithListExample
313+ {
314+ ItemWithListName = "ItemList 1L" ,
315+ Claims = new List < string >
316+ {
317+ "ItemList Claim 1L-0L" ,
318+ " " , // whitespace
319+ } ,
320+ } ,
321+ new ItemWithListExample
322+ {
323+ ItemWithListName = "ItemList 2L" ,
324+ Claims = null
325+ } ,
326+ new ItemWithListExample
327+ {
328+ ItemWithListName = "ItemList 3L" ,
329+ Claims = new List < string >
330+ {
331+ "ItemList Claim 3L-0L" ,
332+ "ItemList Claim 3L-1L" ,
333+ "ItemList Claim 3L-2L" ,
334+ "ItemList Claim 3L-3L" ,
335+ "ItemList Claim 3L-4L" ,
336+ "ItemList Claim 3L-5L" ,
337+ } ,
338+ } ,
339+ } ,
288340 } ;
289341
290342 [ Theory ]
@@ -298,6 +350,17 @@ public void Fails_on_Items_Child2_SimpleA_BoolC()
298350 [ InlineData ( "ItemsCollection[3].SimpleA.IntegerA" ) ]
299351 [ InlineData ( "ItemsCollection[3].SimpleA.StringB" ) ]
300352 [ InlineData ( "ItemsList[1].SimpleA.ExampleEnumD" ) ]
353+ [ InlineData ( "ItemWithListExamples[0].ItemWithListName" ) ]
354+ // It would be nice if these would indicate which element in the IEnumerable was not valid.
355+ // That's not easy / almost impossible to do with simple IEnumerable<T> like "string".
356+ // There might be an ValidationAttribute derived class that does it?
357+ // It may be out of scope for the RecursiveDataAnnotationsValidation project.
358+ // It might be possible to report on the FIRST failure in the IEnumerable<T> with the index,
359+ // but that would be the responsibility of whatever inherits from ValidationAttribute.
360+ [ InlineData ( "ItemWithListExamples[0].Claims" ) ]
361+ [ InlineData ( "ItemWithListExamples[1].Claims" ) ]
362+ // ^---- future would output "ItemWithListExamples[x].Claims[y]" for the specific element
363+ [ InlineData ( "ItemWithListExamples[2].Claims" ) ]
301364 public void Multiple_failures_contains_expected_memberName ( string expectedMemberName )
302365 {
303366 var validationResults = new List < ValidationResult > ( ) ;
0 commit comments