notEmpty static method

dynamic notEmpty(
  1. dynamic value, [
  2. String message = DEFAULT_NOT_EMPTY_MESSAGE
])

Validate that the specified argument is neither [null] nor is empty (object must have isEmpty implemented); otherwise throwing an exception with the specified message.

Validate.notEmpty(myArray, "The array must not be empty");

value the value to check, validated not null by this method message the exception message if invalid, not null Returns the validated value (never null method for chaining) Throws ArgumentError if the array is null Throws ArgumentError if the array is empty

Implementation

static notEmpty(final value, [String message = DEFAULT_NOT_EMPTY_MESSAGE]) {
  GValidate.notNull(value, message);
  /*
      if ((value is List || value is Map || value is String) && value.length == 0) {
          throw new ArgumentError(message);
      }
      */
  if (value.isEmpty) {
    throw new ArgumentError(message);
  }

  return value;
}