passes method
Validates the value using the given context.
Returns true if valid, otherwise false.
Implementation
@override
FutureOr<bool> passes(ValidationContext context) {
final value = context.value;
if (value == null) return false;
if (value is! String) return false;
final urlRegex = RegExp(
r'^https?://' // protocol
r'(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+' // domain
r'[a-zA-Z]{2,}' // top-level domain
r'(?::\d{1,5})?' // optional port
r'(?:/?|[/?]\S+)$', // path
caseSensitive: false,
);
return urlRegex.hasMatch(value);
}