isValidValue<T> static method
Returns true
if the the given value
is found within validValues
or
if the validValues
list is empty and value
is empty as well.
Implementation
static bool isValidValue<T>(T value, List<T> validValues) {
if (value == null) return false;
if (validValues.isEmpty) {
if (value is String) return value.isEmpty;
if (value is Iterable) return value.isEmpty;
}
return validValues.contains(value);
}