validateAnyOf function

void validateAnyOf(
  1. List values,
  2. List<String> names
)

Validates that at least one value in the given list is not null.

Throws a Exception in the case all values are null.

Implementation

void validateAnyOf(List<dynamic> values, List<String> names) {
  final match = values.firstWhereOrNull((x) => x != null);
  if (match == null) {
    throw Exception('At least one of $names must not be null');
  }
}