I have implemented model validation in some of my APIs, but I was wondering if it is possible to do some validation using attributes on simple parameters, like:
[HttpGet("test/{type}")]
public ActionResult GetSomeData([Range(0,2)]byte type)
{
if (!ModelState.IsValid)
{
// isValid is always TRUE
}
...
}
Run Code Online (Sandbox Code Playgroud)
When you call /controller/test/4, IsValid is always TRUE.
Is there a clean way to do that?
Thanks!