Although it is so late, just add another solution for future developers on 'system.text.json' rather than 'Newtonsoft json':
The key for that is 'json schema' as @steve-py answered, but library of Newtonsoft's JSON validation is not free. There is library LateApexEarlySpeed.Json.Schema which is free and supports 'json schema generation from .net type' and also passed json schema v2020.12 official test suite.
For your validation part, just write as:
public class Properties
{
[Required]
[JsonPropertyName("civic_number")]
public string CivicNumber { get; set; }
[JsonPropertyName("address")]
public string Address { get; set; }
[JsonPropertyName("postal_code")]
public string PostalCode { get; set; }
[JsonPropertyName("city_name")]
public string CityName { get; set; }
}
JsonValidator jsonValidator = JsonSchemaGenerator.GenerateJsonValidator<Properties>();
ValidationResult validationResult = jsonValidator.Validate("""
{
"civic_number": "100",
"address": "100, king street",
"postal_code": "H0H0H0",
"city_name": "Windsor"
}
""");
Assert.True(validationResult.IsValid);
Don't forget to use 'System.Text.Json.Serialization.JsonPropertyNameAttribute' because it is System.Text.Json based. (I am author of this library)