ValidateParamCollection static method

void ValidateParamCollection(
  1. Iterable collection,
  2. String paramName
)
Validates parameter collection. The collection. Name of the param.

Implementation

static void ValidateParamCollection(Iterable collection, String paramName) {
  ValidateParam(collection, paramName);

  int count = 0;

  for (Object? obj in collection) {
    try {
      ValidateParam(obj, "collection[$count]");
    } on ArgumentException catch (e) {
      throw new ArgumentException("""
                      string.Format("The element at position {0} is invalid", count),
                      paramName,
                      $e""");
    }

    count++;
  }

  if (count == 0) {
    throw new ArgumentException("Strings.CollectionIsEmpty, paramName");
  }
}