Im trying to exclude a required property(Password) so the modelstate dont validate that property, but for some reason it still validate even when i try to exclude it.
<You could use an extension method like so:
public static bool IsValidExclude(this ModelStateDictionary modelState, params string[] exclude)
{
foreach (var key in exclude)
{
if (modelState.ContainsKey(key))
modelState.Remove(key);
}
return modelState.All(m => m.Value.Errors.Count == 0);
}
Then just call:
var result = ModelState.IsValidExclude("Password");