I have a class
class A {
propA { get; set; }
propB { get; set; }
propC { get; set; }
target { get; set; }
}
I work out the target of class A and populate the class with user input. Each different target will mean different properties of the class are required(not empty/null).
So if my target is banana, then propA and propB must not be empty. If apple, then propB and propC must not be empty. I need to do this at the start of the application as to not keep doing checks in a later stage, as some methods and DB calls will require data etc.
What's the best way to code this? or even design-wise. Is it good practice to store what properties are required for each target in an enum? And then use what lazyberezovsky provided below to go through and check??
The above example only has 3 properties, but what I'm actually required to do has heaps more.
I only just started looking at ways to validate my code.
In summary, there are two parts to this question. - How to check whether a property of a class is empty - Storing a lists of different combined required properties somewhere to use against how to check
EDIT: sorry! I've edited to hopefully make more sense out of this.