I have the following Model:
public class Person
{
public string Name {get;set;}
public Address Address {get;set;}
}
public class Address
{
public string Street {get;set;}
public string City {get;set}
}
I have now created a ModelValidator for which validates Person objects. The ModelValidator has one method to implement:
public abstract System.Collections.Generic.IEnumerable<ModelValidationResult>
Validate(object container)
In this case how do I indicate that an error has occurred for the Address.Street property of the Person object. I have tried setting the ModelValidationResult.MemberName to Address.Street but this is not working?
How do I accomplish this?
My bad, it does work.
In the above example, setting the Member property of the Model Validation Error to “Address.City” does highlight the city field.
Thanks