url static method

FormFieldValidator<String> url({
  1. List<String> protocols = const <String>['http', 'https', 'ftp'],
  2. bool requireTld = true,
  3. bool requireProtocol = false,
  4. bool allowUnderscore = false,
  5. List<String> hostWhitelist = const <String>[],
  6. List<String> hostBlacklist = const <String>[],
  7. RegExp? regex,
  8. String? errorText,
  9. bool checkNullOrEmpty = true,
})

FormFieldValidator that requires the field's value to be a valid URL.

Parameters:

  • protocols The list of allowed protocols (default: 'http', 'https', 'ftp').
  • requireTld Whether TLD is required (default: true).
  • requireProtocol Whether protocol is required for validation.
  • allowUnderscore Whether underscores are allowed.
  • hostWhitelist The list of allowed hosts.
  • hostBlacklist The list of disallowed hosts.
  • regex The regex pattern to match.
  • errorText The error message when the URL is invalid.
  • checkNullOrEmpty Whether 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;