noNullElements static method
Validate that the specified argument array is neither [null] nor contains any elements that are [null]; otherwise throwing an exception with the specified message.
Validate.noNullElements(myArray, "The validated array contains null element");
If the array is [null], then the message in the exception is "The validated object is null".
iterable
the Iterable to check, validated not null by this method
message
the exception message if invalid, not null
Returns the validated iterable (never null
method for chaining)
Throws ArgumentError if the iterable is null
Throws ArgumentError if an element is null
Implementation
static Iterable noNullElements(Iterable iterable,
[String message = DEFAULT_NO_NULL_ELEMENTS_ARRAY_EX_MESSAGE]) {
DartValidate.notNull(iterable);
for (var x in iterable) {
if (x == null) {
throw new ArgumentError(message);
}
}
return iterable;
}