Validation messages for fields in collections

Jan 8, 2010 at 12:39 PM


I have a list of items with indexed names, ie:

Skills[0].Name = "C#"

Skills[1].Name = "SQL"

Skills[2].Name = "OO"

In the controller method, each item is validated before being added to the database. If one fails validation, I get the ErrorInfo object and use RulesException.AddModelStateErrors(ModelState, "Skills");

However this does not populate the ModelState with the correct id for the element, as it uses the plain property name (in this case "Name") without the indexing. So the id in the ModelState is "Skills.Name".

XVal should provide support for indexed items, maybe you can add it in another release. In the meantime I have a problem because I cannot get the XVal sourcecode and make the modifications myself.