validateWebsiteNullable static method
Version of validateWebsite that does not care if the value is null, useful for social links.
Implementation
static String? validateWebsiteNullable(String? value) {
if (value == null || value == '') {
return null;
}
final regex = RegExp(
r'^(https?|ftp)://[^\s/$.?#].\S*$',
caseSensitive: false,
multiLine: false,
);
if (!regex.hasMatch(value)) {
return 'Value must be a valid website URL';
}
return null;
}