validateEndpoint static method
Validates that an endpoint URL is reachable and properly formatted
Implementation
static Future<List<String>> validateEndpoint(String endpoint) async {
final issues = <String>[];
if (endpoint.isEmpty) {
issues.add('Endpoint cannot be empty');
return issues;
}
final uri = Uri.tryParse(endpoint);
if (uri == null) {
issues.add('Endpoint must be a valid URL');
return issues;
}
if (!uri.hasScheme ||
!['http', 'https'].contains(uri.scheme.toLowerCase())) {
issues.add('Endpoint must use http or https scheme');
}
if (!uri.hasAuthority) {
issues.add('Endpoint must include a host');
}
// Additional validation could include:
// - DNS resolution check
// - HTTP connectivity test
// - SSL certificate validation for HTTPS
// These would be implemented in a more comprehensive validation
return issues;
}