Clean your code, not your laptop

A person cleaning a Laptop. Is this clean code?
enum EmailValidationError { invalid }class Form1 extends FormzInput<String, Form1ValidationError> {
const Form1.pure() : super.pure('');
const Form1.dirty([String value = '']) : super.dirty(value);

static final String _form1RegexString =
r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+";

static final RegExp _form1Regex = RegExp(_form1RegexString);

@override
Form1ValidationError? validator(String? value) {
return _form1Regex.hasMatch(value!) ? null : Form1ValidationError.invalid;
}
}
enum EmailValidationError { invalid }

class Email extends FormzInput<String, EmailValidationError> {
const Email.pure() : super.pure('');
const Email.dirty([String value = '']) : super.dirty(value);

static final String _emailRegexString =
r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+";

static final RegExp _emailRegex = RegExp(_emailRegexString);

@override
EmailValidationError? validator(String? value) {
return _emailRegex.hasMatch(value!) ? null : EmailValidationError.invalid;
}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store