RegexModel.noRepeating constructor

RegexModel.noRepeating({
  1. int count = 3,
  2. String? title,
})

No character count or more times in a row ("aaa" for 3).

Implementation

factory RegexModel.noRepeating({int count = 3, String? title}) {
  assert(count >= 2, 'count must be at least 2');
  final repeat = RegExp('(.)\\1{${count - 1}}');
  return RegexModel(
    title: title ?? RegexLabels.current.noRepeating(count),
    test: (value) => !repeat.hasMatch(value),
  );
}