For this type of validation, many languages use a method or property called IsEmpty. During the hydration phase of the object, a logical flag is set indicating whether the object is empty or not. Then you can simply use the property or method elsewhere to check for empty objects.
t
During hydration
bool _isEmpty = false;
if( prop1 is empty && prop2 is empty )
{
_isEmpty = true;
}
else
{
_isEmpty = false;
}
Then use the property IsEmpty
IsEmpty
{
get { return _isEmpty; }
}
source
share