A User in my system can have Email, Mobile or Phone and based on the values passed I am checking some conditions and then setting the ContactDataStatus (which is an enum) for each. I am then checking the ContactDataStatus to determine whether the provided contact details were valid.
The enum has the following definition
public enum ContactDataStatus
{
ExistsButUnverified = 1,
ExisitsAndVerified = 2,
IsValid = 3,
IsUninitialized = 4
}
I wrote the following if conditions to set isValid variable
isValid = false;
if (emailStatus == ContactDataStatus.IsValid &&
(mobileStatus == ContactDataStatus.IsValid ||
mobileStatus == ContactDataStatus.IsUninitialized)
&& (phoneStatus == ContactDataStatus.IsValid ||
phoneStatus == ContactDataStatus.IsUninitialized))
{
isValid = true;
}
else if (mobileStatus == ContactDataStatus.IsValid &&
(emailStatus == ContactDataStatus.IsValid ||
emailStatus == ContactDataStatus.IsUninitialized) &&
(phoneStatus == ContactDataStatus.IsValid ||
phoneStatus == ContactDataStatus.IsUninitialized))
{
isValid = true;
}
else if (phoneStatus == ContactDataStatus.IsValid &&
(emailStatus == ContactDataStatus.IsValid ||
emailStatus == ContactDataStatus.IsUninitialized) &&
(mobileStatus == ContactDataStatus.IsValid ||
mobileStatus == ContactDataStatus.IsUninitialized))
{
isValid = true;
}
Is there a simpler/shorter way of writing this?