isValid method
Validates input string against the pattern type.
Implementation
bool isValid(String input) {
switch (this) {
case PatternType.email:
return RegExp(
r'^[\w-]+(\.[\w-]+)*@([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,7}$',
).hasMatch(input);
case PatternType.phone:
return RegExp(r'^\+?[0-9]{10,15}$').hasMatch(input);
case PatternType.number:
return RegExp(r'^\d+$').hasMatch(input);
case PatternType.strongPassword:
return _validateStrongPassword(input);
}
}