Is it possible to update ModelState.IsValid manually?

You can use the addModelError

ModelState.AddModelError(key,message)

when you use that, it will invalidate the ModelState so isValid will return false.


Update
after seeing the comment to @Pieter’s answer

If you want to exclude an element from affecting the isValid() result, you can use the ModelState.Remove(field) method before calling isValid().

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)