Last active
January 19, 2016 19:33
-
-
Save JoseGonzalez321/29f6b10594b19ffa7d79 to your computer and use it in GitHub Desktop.
Simple validation for parameter types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static bool AreParamsValid(object[] parameters) | |
{ | |
if (parameters == null || parameters.Length == 0) | |
return false; | |
var result = true; | |
parameters.ForEach(p => | |
{ | |
if (p is string) | |
{ | |
if (string.IsNullOrEmpty(p as string)) | |
result = false; | |
} | |
else if (p is DateTime) | |
{ | |
var dateTime = (DateTime)p; | |
if (dateTime.equals(DateTime.Min)) | |
result = false; | |
} | |
}); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment