I'm using C# & Restsharp in order to create HTTP calls to one of our APIs. I'm struggling with the Response retrieved by the API. I'd like to validate the model structure but didn't find any decent way of doing that on my side (handling the response).
For instance, I have a DTO object as the following:
public class User
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string PhoneNumber { get; set; }
}
Sometimes, the Response object can include only the FirstName, without having the LastName and PhoneNumber at all and sometimes it might include more properties (Country, PostalCode, etc...).
I should validate that the User
model only includes the above (FirstName, LastName and PhoneNumber). Nothing more, and nothing that is missing.
What's the best approach to doing that?