validateTimeValue function

Validator validateTimeValue(
  1. int minSeconds,
  2. int maxSeconds
)

Shortcut for a validator that ensures that a time is within certain bounds

For example: greater than or equal to 20 seconds and less than 10 hours This is mostly here for specific implementations to add additional limitations/validation to commands if desired

Implementation

Validator validateTimeValue(int minSeconds, int maxSeconds) {
  return validate(
      (data) => (data as Duration).lengthIsBetween(minSeconds, maxSeconds),
      (data) => ArgumentError(
          "Provided Duration of ${(data as Duration).inMilliseconds / Duration.millisecondsPerSecond} seconds does not round to a value within the allowed limits. Expected a value from $minSeconds to $maxSeconds seconds."));
}