Doesn't support List item validation?

Apr 5, 2011 at 8:34 PM
Edited Apr 5, 2011 at 8:39 PM

I've just mocked up a sample here to demonstrate the issue I'm trying to convey, this is not exactly what I'm doing but very similar in structure...

If I have a couple ViewModels as such: (The main concern here being the "List<Address> Addresses" property of the PersonViewModel)

public class PersonViewModel
{
    public string Name { get; set; }
    public List<Address> Addresses { get; set; }
}

public class Address
{
    public string Address1 { get; set; }
    public string Address2 { get; set; }

    [RequiredIfNotEmpty("Address1")]
    public string City { get; set; }

    [RequiredIfNotEmpty("Address1")]
    public string State { get; set; }

    [RequiredIfNotEmpty("Address1")]
    public string Zip { get; set; }
}
When this is rendered to the page, the HTML name attribute for properties in the addresses list for a person would be something like: (if the person had 2 addresses in the list)
<input id="Name" name="Name" type="text" />
<input id="Address1" name="Addresses[0].Address1" type="text" />
<input id="Address2" name="Addresses[0].Address2" type="text" />
<input id="City" name="Addresses[0].City" type="text" data-val-requiredifnotempty-dependentproperty="Address1" data-val-requiredifnotempty="Required field" data-val="true" />
<input id="State" name="Addresses[0].State" type="text" data-val-requiredifnotempty-dependentproperty="Address1" data-val-requiredifnotempty="Required field" data-val="true" />
<input id="Zip" name="Addresses[0].Zip" type="text" data-val-requiredifnotempty-dependentproperty="Address1" data-val-requiredifnotempty="Required field" data-val="true" />

<input id="Address1" name="Addresses[1].Address1" type="text" />
<input id="Address2" name="Addresses[1].Address2" type="text" />
<input id="City" name="Addresses[1].City" type="text" data-val-requiredifnotempty-dependentproperty="Address1" data-val-requiredifnotempty="Required field" data-val="true" />
<input id="State" name="Addresses[1].State" type="text" data-val-requiredifnotempty-dependentproperty="Address1" data-val-requiredifnotempty="Required field" data-val="true" />
<input id="Zip" name="Addresses[1].Zip" type="text" data-val-requiredifnotempty-dependentproperty="Address1" data-val-requiredifnotempty="Required field" data-val="true" />
It doesn't seem like the FoolProof Validation can currently handle elements generated from lists, however, is there any plan to add support for this?
Thanks,
Austin