MVC: Only me or IsValidField is illogical
While I was writing some code to print JS when a field is invalid in ModelState
, came up with the following method:
ModelState.IsValidField(string key)
A comment in IntelliSense tells me:
Returns true if there is any System.Web.Mvc.ModelError associated with or prefixed with a specific key.
While I am asking if the field is valid, it will return false
in case it is invalid, and true
if it is valid.
It seems rather counterintuitive, but I haven't found any resources on the Internet to support it.
+2
source to share
2 answers