maxVotesPerPersonValidationError method

  1. @override
String? maxVotesPerPersonValidationError(
  1. int votes,
  2. Range<int> range
)

The error shown when the max votes is not within the range.

Returns 'Vote count must be at least ${range.min}' if the vote count is too short and 'Vote count must be at most ${range.max}' if the vote count is too long.

Implementation

@override
String? maxVotesPerPersonValidationError(int votes, Range<int> range) {
  final (:min, :max) = range;

  if (min != null && votes < min) {
    return '投票数は$min以上である必要があります';
  }

  if (max != null && votes > max) {
    return '投票数は最大$max票でなければなりません';
  }

  return null;
}