mirror of
https://github.com/foss42/apidash.git
synced 2025-12-01 02:07:00 +08:00
19 lines
561 B
Dart
19 lines
561 B
Dart
import 'package:apidash_core/apidash_core.dart';
|
|
|
|
String? getValidationResult(HttpRequestModel requestModel) {
|
|
if (requestModel.url.trim().isEmpty) {
|
|
return 'Request URL is empty. Please provide a valid URL.';
|
|
}
|
|
if (requestModel.method == HTTPVerb.get && requestModel.hasAnyBody) {
|
|
return 'GET request contains a body. This is not supported.';
|
|
}
|
|
if (requestModel.hasJsonData) {
|
|
try {
|
|
kJsonDecoder.convert(requestModel.body!);
|
|
} catch (e) {
|
|
return 'Invalid JSON in request body: ${e.toString()}';
|
|
}
|
|
}
|
|
return null;
|
|
}
|