views:

72

answers:

2

While I was writing some code to print out JS when a field is not valid in the ModelState is came to the following method:

ModelState.IsValidField(string key)

The comment in IntelliSense tells me:

Returns true if there is any System.Web.Mvc.ModelError associated or prefixed with the specific key.

While I ask whether a field is valid it will return false in case it is not valid and true if it is valid.

This seems quite illogical, yet I haven't found any resource on the web that confirms this.

A: 

I think that is to say whether this field requires Validation not whether if it is valid. though you have a point in that it seems to be misleading. Might have to dig deeper for reasoning here or naming.

dove
A: 

Did another simple test, and actually the method does behave as it should, the description in IntelliSense is just misleading.

Gidon