Skip to main content

validateFirstName method

String? validateFirstName (String value)

Implementation

static String? validateFirstName(String value) \{
if (value.isEmpty) \{
return 'Firstname must not be left blank.';
\}
ignore: unnecessary_raw_strings
const String pattern = r'(?=.*?[A-Za-z]).+';
final RegExp regex = RegExp(pattern);
if (!regex.hasMatch(value)) \{
return "Invalid Firstname";
\}
return null;
\}