url<T> static method
when valid
- value is null
- value is an url
Implementation
static FormeValidator<T> url<T>({
String errorText = '',
String? schema,
String? host,
int? port,
}) {
return (f, T v) {
if (v == null || (v as String).isEmpty) {
return null;
}
final Uri? uri = Uri.tryParse(v);
if (uri == null) {
return errorText;
}
if (schema != null && schema.isNotEmpty && !uri.isScheme(schema)) {
return errorText;
}
if (host != null && host.isNotEmpty && uri.host != host) {
return errorText;
}
if (port != null && uri.port != port) {
return errorText;
}
return null;
};
}