mirrored_repositories/flutter-objectbox-example/lib
import 'package:formz/formz.dart';

enum NameValidationError { invalid }

class Name extends FormzInput<String, NameValidationError> {
  const Name.pure() : super.pure('');
  const Name.dirty([String name = '']) : super.dirty(name);

  static final RegExp _nameRegExp = RegExp(r'^.{1,20}$');

  @override
  NameValidationError? validator(String value) {
    return _nameRegExp.hasMatch(value) ? null : NameValidationError.invalid;
  }
}
