I need to have properties in a subclass of the base class for two endpoints in my API to be required one one endpoint and optional in the other.
public class Endpoint1RequestModel : BaseClass
{
// Other properties specific to this endpoint here
}
public class Endpoint2RequestModel : BaseClass
{
// Other properties specific to this endpoint here
}
public class BaseClass
{
// Other shared properties here
public PropertyInfo Property { get; set; }
}
public class PropertyInfo
{
public string Address { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
}
I need for the setup for Endpoint1 to be:
public class PropertyInfo
{
public string Address { get; set; }
public string City { get; set; }
[Required]
public string State { get; set; }
[Required]
public string Zip { get; set; }
}
And for Endpoint 2:
public class PropertyInfo
{
[Required]
public string Address { get; set; }
[Required]
public string City { get; set; }
[Required]
public string State { get; set; }
[Required]
public string Zip { get; set; }
}
I have tried a few things and just couldn't quite get it to function how I want it to.