I have below web api method as below
public bool UpdateValidations([FromBody] ValidationKeyEntity validationKey)
{
if (ModelState.IsValid)
{
//my code here
}
}
public class ValidationKeyEntity
{
public int ValidationKeyId { get; set; }
[MaxLength(Constants.maxStringLength)]
public string Name { get; set; }
public int DisplayId { get; set; }
[MaxLength(Constants.maxStringLength)]
public string CreatedBy { get; set; }
}
I am doing testing using Postman .I am passing different json than ValidationKeyEntity object as { "Vishal": "vishal" } as parameter . But still my ModelState.IsValid returns true.
How can I avoid accepting other json object than "ValidationKeyEntity" object?