I'm trying to add CustomValidation and make it return error for
Html.ValidationMessageFor(m => m.SubleaseCompany)
[CustomValidation(typeof(CreateSpaceModelValidation), "ValidateCreateSpaceModel")]
public class CreateSpaceModel
{
public Building Building { get; set; }
public Space Space { get; set; }
public string SubleaseCompany { get; set; }
}
public class CreateSpaceModelValidation
{
public static ValidationResult ValidateCreateSpaceModel(CreateSpaceModel model)
{
return new ValidationResult("You should specify Sublease Contact", new[] { "SubleaseCompany" }).;
}
}
I'm using second argument for ValidationResult constructor (memberNames) but this doesn't seem to work.