How do you validate a JObject input parameter to a controller method? I am wondering is there any framework supported functions to validate easily?
Right now I am validating against null, if it is not null the JObject is parsed and populated the DTO object and complete the business process.
My controller method looks like below:
public async Task<IActionResult> Login([FromBody]JObject jObject)
{
try
{
if (jObject != null)
{
TokenDTO SiBagToken = await _account.Login(jObject);
return SuccessStatusCode;
}
else
{
return NoContentStatusCode;
}
}
catch(Exception ex)
{
return errorstatuscode;
}
}
Here is the DTO object looks like:
public class AccountDTO
{
public string UserName { get; set; }
public string Password { get; set; }
public string oldPassword { get; set; }
}