I have an enum:
public enum TaxType : byte
{
None = 0,
GSTCanada = 5,
HSTOntario = 13,
HSTOther = 15
}
It is given in the json by a number. Eg:
{"TaxType": 13, ...}
public class OrderInfo
{
public TaxType TaxType { get; set; }
/// ...
}
It will successfully deserialize but I want to throw an exception if the value is NOT (0 OR 5 OR 13 OR 15).
Is that possible to do via an attribute using System.Text.Json?