We use a lot of repetitive code in our actions. ♻️
Inside of our controller actions we usually check if the model is valid by using ModelState property available on MVC’s base controller class :
if (!ModelState.IsValid)
return BadRequest(ModelState);
The bad thing about is that we repeat this piece of code throughout a lot of our actions. ❌
How we can make it better❓
This article shows you how to validate ModelState with a global filter. 💎
https://t.me/pgimg/112
[ Article ] : bit.do/mval
〰〰〰〰〰〰
#AspMvc #Core #Validation
@ProgrammingTip