url static method
FormFieldValidator<String>
url({
- List<
String> protocols = const <String>['http', 'https', 'ftp'], - bool requireTld = true,
- bool requireProtocol = false,
- bool allowUnderscore = false,
- List<
String> hostWhitelist = const <String>[], - List<
String> hostBlacklist = const <String>[], - RegExp? regex,
- String? errorText,
- bool checkNullOrEmpty = true,
FormFieldValidator that requires the field's value to be a valid URL.
Parameters:
protocolsThe list of allowed protocols (default:'http', 'https', 'ftp').requireTldWhether TLD is required (default: true).requireProtocolWhether protocol is required for validation.allowUnderscoreWhether underscores are allowed.hostWhitelistThe list of allowed hosts.hostBlacklistThe list of disallowed hosts.regexThe regex pattern to match.errorTextThe error message when the URL is invalid.checkNullOrEmptyWhether to check for null or empty values.
Implementation
static FormFieldValidator<String> url({
List<String> protocols = const <String>['http', 'https', 'ftp'],
bool requireTld = true,
bool requireProtocol = false,
bool allowUnderscore = false,
List<String> hostWhitelist = const <String>[],
List<String> hostBlacklist = const <String>[],
RegExp? regex,
String? errorText,
bool checkNullOrEmpty = true,
}) => UrlValidator(
protocols: protocols,
requireTld: requireTld,
requireProtocol: requireProtocol,
allowUnderscore: allowUnderscore,
hostWhitelist: hostWhitelist,
hostBlacklist: hostBlacklist,
regex: regex,
errorText: errorText,
checkNullOrEmpty: checkNullOrEmpty,
).validate;